آ XTERM021.BCK@  XTERM021.BCKLBACKUP [...]*.*.* USERS:[ANONYMOUS.PUBLIC.MAHAN]XTERM021.BCK/SAVE/BLOCK=2048 MAHAN @ ERT6.0 _GEMINI::  _HQ$DKA300: V6.0  *[MAHAN.XTERM]00-AUTHOR.;3+,\r ./@ 4Hv-`0123KPWO567 G7F G8M9G@HJ>xterm was written by a bunch of people; see HELP XTERM AUTHORSfor their names.HThe port to VMS was done by Stephan Jansen 6of the University of Wisconsin-Madison Astronomy Dept.GThe port to X11R4 for VMS was done by Patrick L. Mahan .?Aaron Leonard bundled it up and inflictedit on the net.*[MAHAN.XTERM]000README.VMS;6+,]r ./@ 4M-`0123KPWO56؁G7ZG8PM9G@HJ XTERM021.BCK]r `[MAHAN.XTERM]000README.VMS;6METhis is XTERM V2.0 for VMS, the VT102 and Tektronix 4014 emulator forFXwindows. This version is known to work under VMS V5.4-x. To rebuild=this, execute MAKE.COM. If you are running a version of VMS <between VMS V5.1-x thru 5.3-x, then you must run XTERM V1.1.5 **** NOTICE **** NOTICE **** NOTICE **** NOTICE ****4 This version requires DECwindows/Motif be installed3 on your system. If you don't have Motif, then you3 won't be able to build it. As of the date of this4 port it was my impression that Digital was probably3 not going to upgrade the regular old DECwindows to X11R4.5 **** NOTICE **** NOTICE **** NOTICE **** NOTICE ****JThere are a number of features of Xterm that are not implemented under VMSIeither because they do not make sense in VMS or because I didn't have thetime to make them work.GThere are two important points about the behavior of the VMS version ofXterm.J o The terminal only has input focus (ie. accepts keyboard input) whenM the window is both selected (ie. the top of the window is highlighted)0 and the cursor is in the terminal window.HThis version of Xterm is capable of setting the terminal width and page Hsize based on the geometry specified either in the command line or usingEthe xterm resource file (in the file decw$user_defaults:xterm.dat). Starting up XtermFontsH It appears that a number of the "standard" X fonts are not availableJ under DECWindows. In order to find which fonts are available anuB XTERM021.BCK]r `[MAHAN.XTERM]000README.VMS;6Mj d whatF their full names are, get the program XLSFONTS available for both4 DECwindows (X11R3) and DECwindows/Motif (X11R4).*[MAHAN.XTERM]ACCESS.H;2+,^r ./@ 4&-`0123KPWO56` ClE7PlE809&N9G@HJ/* * access.h& * defines for access library function */#ifndef _ACCESS_H#define _ACESS_H#define F_OK 0#define X_OK 1#define W_OK 2#define R_OK 4#endif /* _ACCESS_H */*[MAHAN.XTERM]BUTTON.C;3+,_r.K/@ 4SKGj-`0123KPWOH561euD7luD8.N9G@HJt]i@ XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SKM/* * $XConsortium: button.c,v 1.49 89/12/10 20:45:17 jim Exp $ */ #ifdef vax11c #include #else #include #endif /* vax11c */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * 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, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* button.c Handles button events in the terminal emulator. does cut/paste operations, change modes via menu, passes button events through to some applications. J. Gettys. */ #ifndef lint static char rcs_id[] = "$XConsortium: button.c,v 1.49 89/12/10 20:45:17 jim Exp) XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SKH $"; #endif /* lint */ #include "ptyx.h" /* Xlib headers included here. */ #ifdef vax11c #include #else #include #endif /* vax11c */ #include #include #include #ifdef vax11c #include #include #else #include #include #endif /* vax11c */ #include "data.h" #include "error.h" #include "menu.h" extern char *malloc(); #define KeyState(x) (((x) & (ShiftMask|ControlMask)) + (((x) & Mod1Mask) ? 2 : 0)) /* adds together the bits: shift key -> 1 meta key -> 2 control key -> 4 */ #define TEXTMODES 4 #define NBUTS 3 #define DIRS 2 #define UP 1 #define DOWN 0 #define SHIFTS 8 /* three keys, so eight combinations */ #define Coordinate(r,c) ((r) * (term->screen.max_col+1) + (c)) char *SaveText(); extern EditorButton(); extern char *xterm_name; extern Bogus(); static PointToRowCol(); extern XtermWidget term; /* Selection/extension variables */ /* Raw char position where the selection started */ static int rawRow, rawCol; /* Selected area before CHAR, WORD, LINE selectUnit processing */ static int startRRow, startRCol, endRRow, endRCol = 0; /* Selected area after CHAR, WORD, LINE selectUnit processing */ static int startSRow, startSCol, endSRow, endSCol = 0; /* Valid rows for selection clipping */ static int firstValidRow, lastValidRow; /* Start, end of extension */ static int startERow, startECol, endERow, endECol; /* Saved values of raw seI, XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SK>lection for extend to restore to */ static int saveStartRRow, saveStartRCol, saveEndRRow, saveEndRCol; /* Multi-click handling */ static int numberOfClicks = 0; static long int lastButtonUpTime = 0; typedef int SelectUnit; #define SELECTCHAR 0 #define SELECTWORD 1 #define SELECTLINE 2 #define NSELECTUNITS 3 static SelectUnit selectUnit; /* Send emacs escape code when done selecting or extending? */ static int replyToEmacs; Boolean SendMousePosition(w, event) Widget w; XEvent* event; { register TScreen *screen = &((XtermWidget)w)->screen; static TrackDown(); if (screen->send_mouse_pos == 0) return False; if (event->type != ButtonPress && event->type != ButtonRelease) return False; #define KeyModifiers \ (event->xbutton.state & (ShiftMask | LockMask | ControlMask | Mod1Mask | \ Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask )) #define ButtonModifiers \ (event->xbutton.state & (ShiftMask | LockMask | ControlMask | Mod1Mask | \ Mod2Mask | Mod3Mask | Mod4Mask | Mod5Mask )) switch (screen->send_mouse_pos) { case 1: /* X10 compatibility sequences */ if (KeyModifiers == 0) { if (event->type == ButtonPress) EditorButton(event); return True; } return False; case 2: /* DEC vt200 compatible */ if (KeyModifiers == 0 || KeyModifiers == ControlMask) { EditorButton(event); return True; } return False; case 3: /* DEC vt200 hilite tracking */ if ( event->type == ButtonPress && KeyModifiers == 0 && event->xbuttonǓZ_ XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SKq .button == Button1 ) { TrackDown(event); return True; } if (KeyModifiers == 0 || KeyModifiers == ControlMask) { EditorButton(event); return True; } /* fall through */ default: return False; } #undef KeyModifiers } /*ARGSUSED*/ void HandleSelectExtend(w, event, params, num_params) Widget w; XEvent *event; /* must be XMotionEvent */ String *params; /* unused */ Cardinal *num_params; /* unused */ { register TScreen *screen = &((XtermWidget)w)->screen; int row, col; screen->selection_time = event->xmotion.time; switch (eventMode) { case LEFTEXTENSION : case RIGHTEXTENSION : PointToRowCol (event->xmotion.y, event->xmotion.x, &row, &col); ExtendExtend (row, col); break; case NORMAL : /* will get here if send_mouse_pos != 0 */ break; } } /*ARGSUSED*/ static void do_select_end (w, event, params, num_params, use_cursor_loc) Widget w; XEvent *event; /* must be XButtonEvent */ String *params; /* selections */ Cardinal *num_params; Bool use_cursor_loc; { ((XtermWidget)w)->screen.selection_time = event->xbutton.time; switch (eventMode) { case NORMAL : (void) SendMousePosition(w, event); break; case LEFTEXTENSION : case RIGHTEXTENSION : EndExtend(event, params, *num_params, use_cursor_loc); break; } } void HandleSelectEnd(w, event, params, num_params) Widget w; XEvent *event; /* must be XButtonEvent */ String *params; /* selections */ Cardinal *num_params; { do_select_end (w, event, params, num_pa>p XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SK@' rams, False); } void HandleKeyboardSelectEnd(w, event, params, num_params) Widget w; XEvent *event; /* must be XButtonEvent */ String *params; /* selections */ Cardinal *num_params; { do_select_end (w, event, params, num_params, True); } struct _SelectionList { String *params; Cardinal count; Time time; }; static void _GetSelection(w, time, params, num_params) Widget w; Time time; String *params; /* selections in precedence order */ Cardinal num_params; { static void SelectionReceived(); Atom selection; int buffer; XmuInternStrings(XtDisplay(w), params, (Cardinal)1, &selection); switch (selection) { case XA_CUT_BUFFER0: buffer = 0; break; case XA_CUT_BUFFER1: buffer = 1; break; case XA_CUT_BUFFER2: buffer = 2; break; case XA_CUT_BUFFER3: buffer = 3; break; case XA_CUT_BUFFER4: buffer = 4; break; case XA_CUT_BUFFER5: buffer = 5; break; case XA_CUT_BUFFER6: buffer = 6; break; case XA_CUT_BUFFER7: buffer = 7; break; default: buffer = -1; } if (buffer >= 0) { register TScreen *screen = &((XtermWidget)w)->screen; int inbytes; unsigned long nbytes; int fmt8 = 8; Atom type = XA_STRING; char *line = XFetchBuffer(screen->display, &inbytes, buffer); nbytes = (unsigned long) inbytes; if (nbytes > 0) SelectionReceived(w, NULL, &selection, &type, (caddr_t)line, &nbytes, &fmt8); else if (num_params > 1) _GetSelection(w, time, params+1, num_params-1); } else { struct _SelectionL 4 XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SKݾist* list; if (--num_params) { list = XtNew(struct _SelectionList); list->params = params + 1; list->count = num_params; list->time = time; } else list = NULL; XtGetSelectionValue(w, selection, XA_STRING, SelectionReceived, (caddr_t)list, time); } } /* ARGSUSED */ static void SelectionReceived(w, client_data, selection, type, value, length, format) Widget w; caddr_t client_data; Atom *selection, *type; caddr_t value; unsigned long *length; int *format; { int pty = ((XtermWidget)w)->screen.respond; /* file descriptor of pty */ register char *lag, *cp, *end; char *line = (char*)value; if (*type == 0 /*XT_CONVERT_FAIL*/ || *length == 0) { struct _SelectionList* list = (struct _SelectionList*)client_data; if (list != NULL) { _GetSelection(w, list->time, list->params, list->count); XtFree(client_data); } return; } end = &line[*length]; lag = line; for (cp = line; cp != end; cp++) { if (*cp != '\n') continue; *cp = '\r'; v_write(pty, lag, cp - lag + 1); lag = cp + 1; } if (lag != end) v_write(pty, lag, end - lag); XtFree(client_data); XtFree(value); } HandleInsertSelection(w, event, params, num_params) Widget w; XEvent *event; /* assumed to be XButtonEvent* */ String *params; /* selections in precedence order */ Cardinal *num_params; { if (SendMousePosition(w, event)) return; _GetSelection(w, event->xbutton.time, params, *num_params); } SetSelectUnit(buttonDownTime, de ts XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SKyTfaultUnit) unsigned long buttonDownTime; SelectUnit defaultUnit; { /* Do arithmetic as integers, but compare as unsigned solves clock wraparound */ if ((long unsigned)((long int)buttonDownTime - lastButtonUpTime) > term->screen.multiClickTime) { numberOfClicks = 1; selectUnit = defaultUnit; } else { ++numberOfClicks; selectUnit = ((selectUnit + 1) % NSELECTUNITS); } } static void do_select_start (w, event, startrow, startcol) Widget w; XEvent *event; /* must be XButtonEvent* */ int startrow, startcol; { if (SendMousePosition(w, event)) return; SetSelectUnit(event->xbutton.time, SELECTCHAR); replyToEmacs = FALSE; StartSelect(startrow, startcol); } /* ARGSUSED */ HandleSelectStart(w, event, params, num_params) Widget w; XEvent *event; /* must be XButtonEvent* */ String *params; /* unused */ Cardinal *num_params; /* unused */ { register TScreen *screen = &((XtermWidget)w)->screen; int startrow, startcol; firstValidRow = 0; lastValidRow = screen->max_row; PointToRowCol(event->xbutton.y, event->xbutton.x, &startrow, &startcol); do_select_start (w, event, startrow, startcol); } /* ARGSUSED */ HandleKeyboardSelectStart(w, event, params, num_params) Widget w; XEvent *event; /* must be XButtonEvent* */ String *params; /* unused */ Cardinal *num_params; /* unused */ { register TScreen *screen = &((XtermWidget)w)->screen; do_select_start (w, event, screen->cursor_row, screen->cursor_col); } static TrackDown(event) register XButtonEvent *event; { int startrow, startcol; SetS ^C_r`[MAHAN.XTERM]BUTTON.C;3SK[}.L4>pg o@fA2M6"!_5.NIeO L&z2%T [cATy/t-=2I_R>Qd-*Q-b[T;cRvI;&&B}C7A2j`lxJjN~aW 3x[yZ?xlMN=tJR*3tv|H_}M- lU{'w!-Fz 7! 6 <e F g3%oIhpEd:&wVtDF{/'[.FA\ '57xV"B\-FZ <3bJxblsg,=S]W'P/Jv#y10}i |> gYW\qO4J,7{RwxZc|m"-ud4v{[ f,:u-&W;)w\5]{uFj{$]%T N+!~Q+|%~:iwW{KI[X1h =c G-c|>I^Q&Ieo@^@FA 6e2 \,?N ~  GcGmcY@q&d?pX;m{] v JJY(l;P>U.tme w㾠^8 %R= nK'%B:8k]"sKLxpDZX O^- AywyMw/*%t5BD UuQgc;rg}C2#&"y.`T3R0",=V*aZ[I r.e%o ?2\G-1J3cyZn3g{wbAayvOqb]$y@w,xjUb9((p'Z/ 6JmJ@P *R7<2D(}'svx=&QKr_QY7:_= lf/`|eaKotGzTASj @Qq wUpOxI?lAFimL ,(SuG}:)J(l+baL\~bR2֒'~?:ai60h/D33[0mitrjIte\-8$+M*WF +rbLDF~BIEL5?CNr.vbDw2 JM  K Q^E HAM!qe,Kbc ev88I(?84@v}@nGz?c%/4/JgZ"V \]3y33_4{4z21Df7B%`&v(`[CJ|Y7 a;F\@bVa[Ak~ZY| 0:T!L(=ARR(XVNb&,QfuvQ9gSpEN ^pG49oMwQ4 # (<%-d$8?>WA uS,*_BFgVh*uf+.@.9O!2`_F:G-#Lkp h9 (GMix b=?|d[:_Xh{S-`j'`)9P+O1`bmud/1Qy[1(FuXUn" 8^cB8{BHj{%egv*IX,_0iF}}=ym;#l{$-MkFwuMUA:(S!B {cNh;}|@< {Q^(D  Z|bBvP <r"{ L'Ba3i7{|WX/{p-D~qpx?.;>0|{ KzogC~_A\Hg#jie_1N0>oX!TD8>_$kU~9PVL5n=time, SELECTCHAR); if (numberOfClicks > 1 ) { PointToRowCol(event->y, event->x, &startrow, &startcol); replyToEmacs = TRUE; StartSelect(startrow, startcol); } else { waitingForTrackInfo = 1; EditorButton(event); } } #define boundsCheck(x) if (x < 0) \ x = 0; \ else if (x >= screen->max_row) \ x = screen->max_row; TrackMouse(func, startrow, startcol, firstrow, lastrow) int func, startrow, startcol, firstrow, lastrow; { TScreen *screen = &term->screen; if (!waitingForTrackInfo) { /* Timed out, so ignore */ return; } waitingForTrackInfo = 0; if (func == 0) return; boundsCheck (startrow) boundsCheck (firstrow) boundsCheck (lastrow) firstValidRow = firstrow; lastValidRow = lastrow; replyToEmacs = TRUE; StartSelect(startrow, startcol); } StartSelect(startrow, startcol) int startrow, startcol; { TScreen *screen = &term->screen; if (screen->cursor_state) HideCursor (); if (numberOfClicks == 1) { /* set start of selection */ rawRow = startrow; rawCol = startcol; } /* else use old values in rawRow, Col */ saveStartRRow = startERow = rawRow; saveStartRCol = startECol = rawCol; saveEndRRow = endERow = rawRow; saveEndRCol = endECol = rawCol; if (Coordinate(startrow, startcol) < Coordinate(rawRow, rawCol)) { eventMode = LEFTEXTENSION; startERow = startrow; startECol = startcol; } else { eventMode = RIGHTEXTENSION; endERow = startrow; endECol = startcol; } ComputeSelect(startERow, startECol, endERow, endECol, Fal H XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SKXse); } EndExtend(event, params, num_params, use_cursor_loc) XEvent *event; /* must be XButtonEvent */ String *params; /* selections */ Cardinal num_params; Bool use_cursor_loc; { int row, col; TScreen *screen = &term->screen; char line[9]; if (use_cursor_loc) { row = screen->cursor_row; col = screen->cursor_col; } else { PointToRowCol(event->xbutton.y, event->xbutton.x, &row, &col); } ExtendExtend (row, col); lastButtonUpTime = event->xbutton.time; /* Only do select stuff if non-null select */ if (startSRow != endSRow || startSCol != endSCol) { if (replyToEmacs) { if (rawRow == startSRow && rawCol == startSCol && row == endSRow && col == endSCol) { /* Use short-form emacs select */ strcpy(line, "\033[t"); line[3] = ' ' + endSCol + 1; line[4] = ' ' + endSRow + 1; v_write(screen->respond, line, 5); } else { /* long-form, specify everything */ strcpy(line, "\033[T"); line[3] = ' ' + startSCol + 1; line[4] = ' ' + startSRow + 1; line[5] = ' ' + endSCol + 1; line[6] = ' ' + endSRow + 1; line[7] = ' ' + col + 1; line[8] = ' ' + row + 1; v_write(screen->respond, line, 9); } TrackText(0, 0, 0, 0); } SaltTextAway(startSRow, startSCol, endSRow, endSCol, params, num_params); } else DisownSelection(term); /* TrackText(0, 0, 0, 0); */ eventMode = NORMAL; } #define Abs(x) ((x) < 0 ? -(x) : (x)) /* ARGSUSED */ static void do_start_extend (w, event, params, num_params, use_cursor_loc) Widget w; XEventf? XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SK  *event; /* must be XButtonEvent* */ String *params; /* unused */ Cardinal *num_params; /* unused */ Bool use_cursor_loc; { TScreen *screen = &((XtermWidget)w)->screen; int row, col, coord; if (SendMousePosition(w, event)) return; firstValidRow = 0; lastValidRow = screen->max_row; SetSelectUnit(event->xbutton.time, selectUnit); replyToEmacs = FALSE; if (numberOfClicks == 1) { /* Save existing selection so we can reestablish it if the guy extends past the other end of the selection */ saveStartRRow = startERow = startRRow; saveStartRCol = startECol = startRCol; saveEndRRow = endERow = endRRow; saveEndRCol = endECol = endRCol; } else { /* He just needed the selection mode changed, use old values. */ startERow = startRRow = saveStartRRow; startECol = startRCol = saveStartRCol; endERow = endRRow = saveEndRRow; endECol = endRCol = saveEndRCol; } if (use_cursor_loc) { row = screen->cursor_row; col = screen->cursor_col; } else { PointToRowCol(event->xbutton.y, event->xbutton.x, &row, &col); } coord = Coordinate(row, col); if (Abs(coord - Coordinate(startSRow, startSCol)) < Abs(coord - Coordinate(endSRow, endSCol)) || coord < Coordinate(startSRow, startSCol)) { /* point is close to left side of selection */ eventMode = LEFTEXTENSION; startERow = row; startECol = col; } else { /* point is close to left side of selection */ eventMode = RIGHTEXTENSION; endERow = row; endECol = col; } ComputeSelect(startERow, st  XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SK+artECol, endERow, endECol, True); } ExtendExtend (row, col) int row, col; { int coord = Coordinate(row, col); if (eventMode == LEFTEXTENSION && (coord + (selectUnit!=SELECTCHAR)) > Coordinate(endSRow, endSCol)) { /* Whoops, he's changed his mind. Do RIGHTEXTENSION */ eventMode = RIGHTEXTENSION; startERow = saveStartRRow; startECol = saveStartRCol; } else if (eventMode == RIGHTEXTENSION && coord < Coordinate(startSRow, startSCol)) { /* Whoops, he's changed his mind. Do LEFTEXTENSION */ eventMode = LEFTEXTENSION; endERow = saveEndRRow; endECol = saveEndRCol; } if (eventMode == LEFTEXTENSION) { startERow = row; startECol = col; } else { endERow = row; endECol = col; } ComputeSelect(startERow, startECol, endERow, endECol, False); } void HandleStartExtend(w, event, params, num_params) Widget w; XEvent *event; /* must be XButtonEvent* */ String *params; /* unused */ Cardinal *num_params; /* unused */ { do_start_extend (w, event, params, num_params, False); } void HandleKeyboardStartExtend(w, event, params, num_params) Widget w; XEvent *event; /* must be XButtonEvent* */ String *params; /* unused */ Cardinal *num_params; /* unused */ { do_start_extend (w, event, params, num_params, True); } ScrollSelection(screen, amount) register TScreen* screen; register int amount; { register int minrow = -screen->savedlines; /* Sent by scrollbar stuff, so amount never takes selection out of saved text */ /* XXX - the preceeding is false; uO XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SKj"cat /etc/termcap (or anything larger than the number of saved lines plus the screen height) and then hit extend select */ startRRow += amount; endRRow += amount; startSRow += amount; endSRow += amount; rawRow += amount; screen->startHRow += amount; screen->endHRow += amount; if (startRRow < minrow) { startRRow = minrow; startRCol = 0; } if (endRRow < minrow) { endRRow = minrow; endRCol = 0; } if (startSRow < minrow) { startSRow = minrow; startSCol = 0; } if (endSRow < minrow) { endSRow = minrow; endSCol = 0; } if (rawRow < minrow) { rawRow = minrow; rawCol = 0; } if (screen->startHRow < minrow) { screen->startHRow = minrow; screen->startHCol = 0; } if (screen->endHRow < minrow) { screen->endHRow = minrow; screen->endHCol = 0; } screen->startHCoord = Coordinate (screen->startHRow, screen->startHCol); screen->endHCoord = Coordinate (screen->endHRow, screen->endHCol); } /*ARGSUSED*/ ResizeSelection (screen, rows, cols) TScreen *screen; int rows, cols; { rows--; /* decr to get 0-max */ cols--; if (startRRow > rows) startRRow = rows; if (startSRow > rows) startSRow = rows; if (endRRow > rows) endRRow = rows; if (endSRow > rows) endSRow = rows; if (rawRow > rows) rawRow = rows; if (startRCol > cols) startRCol = cols; if (startSCol > cols) startSCol = cols; if (endRCol > cols) endRCol = cols; if (endSCol > cols) endSCol = cols; if (rawCoRмB XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SKk%l > cols) rawCol = cols; } static PointToRowCol(y, x, r, c) register int y, x; int *r, *c; /* Convert pixel coordinates to character coordinates. Rows are clipped between firstValidRow and lastValidRow. Columns are clipped between to be 0 or greater, but are not clipped to some maximum value. */ { register TScreen *screen = &term->screen; register row, col; row = (y - screen->border) / FontHeight(screen); if(row < firstValidRow) row = firstValidRow; else if(row > lastValidRow) row = lastValidRow; col = (x - screen->border - screen->scrollbar) / FontWidth(screen); if(col < 0) col = 0; else if(col > screen->max_col+1) { col = screen->max_col+1; } *r = row; *c = col; } int LastTextCol(row) register int row; { register TScreen *screen = &term->screen; register int i; register Char *ch; for(i = screen->max_col, ch = screen->buf[2 * (row + screen->topline)] + i ; i > 0 && (*ch == ' ' || *ch == 0); ch--, i--); return(i); } static int charClass[128] = { /* NUL SOH STX ETX EOT ENQ ACK BEL */ 32, 1, 1, 1, 1, 1, 1, 1, /* BS HT NL VT NP CR SO SI */ 1, 32, 1, 1, 1, 1, 1, 1, /* DLE DC1 DC2 DC3 DC4 NAK SYN ETB */ 1, 1, 1, 1, 1, 1, 1, 1, /* CAN EM SUB ESC FS GS RS US */ 1, 1, 1, 1, 1, 1, 1, 1, /* SP ! " # $ % & ' */ 32, 33, 34, 35, 36, 37, 38, 39, /* ( ) * + , - . / */ 40, 41, 42, 43, 44, 45, 46, 47, A+U XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SKS(/* 0 1 2 3 4 5 6 7 */ 48, 48, 48, 48, 48, 48, 48, 48, /* 8 9 : ; < = > ? */ 48, 48, 58, 59, 60, 61, 62, 63, /* @ A B C D E F G */ 64, 48, 48, 48, 48, 48, 48, 48, /* H I J K L M N O */ 48, 48, 48, 48, 48, 48, 48, 48, /* P Q R S T U V W */ 48, 48, 48, 48, 48, 48, 48, 48, /* X Y Z [ \ ] ^ _ */ 48, 48, 48, 91, 92, 93, 94, 48, /* ` a b c d e f g */ 96, 48, 48, 48, 48, 48, 48, 48, /* h i j k l m n o */ 48, 48, 48, 48, 48, 48, 48, 48, /* p q r s t u v w */ 48, 48, 48, 48, 48, 48, 48, 48, /* x y z { | } ~ DEL */ 48, 48, 48, 123, 124, 125, 126, 1}; int SetCharacterClassRange (low, high, value) register int low, high; /* in range of [0..127] */ register int value; /* arbitrary */ { if (low < 0 || high > 127 || high < low) return (-1); for (; low <= high; low++) charClass[low] = value; return (0); } ComputeSelect(startRow, startCol, endRow, endCol, extend) int startRow, startCol, endRow, endCol; Bool extend; { register TScreen *screen = &term->screen; register Char *ptr; register int length; register int class; int osc = startSCol; if (Coordinate(startRow, startCol) <= Coordinate(endRow, endCol)) { startSRow = startRRow = startRow; startSCol = startRCoֳ XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SK+l = startCol; endSRow = endRRow = endRow; endSCol = endRCol = endCol; } else { /* Swap them */ startSRow = startRRow = endRow; startSCol = startRCol = endCol; endSRow = endRRow = startRow; endSCol = endRCol = startCol; } switch (selectUnit) { case SELECTCHAR : if (startSCol > (LastTextCol(startSRow) + 1)) { startSCol = 0; startSRow++; } if (endSCol > (LastTextCol(endSRow) + 1)) { endSCol = 0; endSRow++; } break; case SELECTWORD : if (startSCol > (LastTextCol(startSRow) + 1)) { startSCol = 0; startSRow++; } else { ptr = screen->buf[2*(startSRow+screen->topline)] + startSCol; class = charClass[*ptr]; do { --startSCol; --ptr; } while (startSCol >= 0 && charClass[*ptr] == class); ++startSCol; } if (endSCol > (LastTextCol(endSRow) + 1)) { endSCol = 0; endSRow++; } else { length = LastTextCol(endSRow); ptr = screen->buf[2*(endSRow+screen->topline)] + endSCol; class = charClass[*ptr]; do { ++endSCol; ++ptr; } while (endSCol <= length && charClass[*ptr] == class); /* Word select selects if pointing to any char in "word", especially in that it includes the last character in a word. So no --endSCol and do special eol handling */ if (endSCol > length+1) { endSCol = 0; ++endSRow; } } break; case SELECTLINE : if (term->screen.cutToBeginningOfLine) { startSCol = 0; } else if (!extend) Pe XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SK.{ startSCol = osc; } if (term->screen.cutNewline) { endSCol = 0; ++endSRow; } else { endSCol = LastTextCol(endSRow) + 1; } break; } TrackText(startSRow, startSCol, endSRow, endSCol); return; } TrackText(frow, fcol, trow, tcol) register int frow, fcol, trow, tcol; /* Guaranteed (frow, fcol) <= (trow, tcol) */ { register int from, to; register TScreen *screen = &term->screen; int old_startrow, old_startcol, old_endrow, old_endcol; /* (frow, fcol) may have been scrolled off top of display */ if (frow < 0) frow = fcol = 0; /* (trow, tcol) may have been scrolled off bottom of display */ if (trow > screen->max_row+1) { trow = screen->max_row+1; tcol = 0; } old_startrow = screen->startHRow; old_startcol = screen->startHCol; old_endrow = screen->endHRow; old_endcol = screen->endHCol; if (frow == old_startrow && fcol == old_startcol && trow == old_endrow && tcol == old_endcol) return; screen->startHRow = frow; screen->startHCol = fcol; screen->endHRow = trow; screen->endHCol = tcol; from = Coordinate(frow, fcol); to = Coordinate(trow, tcol); if (to <= screen->startHCoord || from > screen->endHCoord) { /* No overlap whatsoever between old and new hilite */ ReHiliteText(old_startrow, old_startcol, old_endrow, old_endcol); ReHiliteText(frow, fcol, trow, tcol); } else { if (from < screen->startHCoord) { /* Extend left end */ ReHiliteText(frow, fcol, old_startrow, old_startcol); } else if (from > scree XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SK1n->startHCoord) { /* Shorten left end */ ReHiliteText(old_startrow, old_startcol, frow, fcol); } if (to > screen->endHCoord) { /* Extend right end */ ReHiliteText(old_endrow, old_endcol, trow, tcol); } else if (to < screen->endHCoord) { /* Shorten right end */ ReHiliteText(trow, tcol, old_endrow, old_endcol); } } screen->startHCoord = from; screen->endHCoord = to; } ReHiliteText(frow, fcol, trow, tcol) register int frow, fcol, trow, tcol; /* Guaranteed that (frow, fcol) <= (trow, tcol) */ { register TScreen *screen = &term->screen; register int i; if (frow < 0) frow = fcol = 0; else if (frow > screen->max_row) return; /* nothing to do, since trow >= frow */ if (trow < 0) return; /* nothing to do, since frow <= trow */ else if (trow > screen->max_row) { trow = screen->max_row; tcol = screen->max_col+1; } if (frow == trow && fcol == tcol) return; if(frow != trow) { /* do multiple rows */ if((i = screen->max_col - fcol + 1) > 0) { /* first row */ ScrnRefresh(screen, frow, fcol, 1, i, True); } if((i = trow - frow - 1) > 0) { /* middle rows*/ ScrnRefresh(screen, frow+1, 0,i, screen->max_col+1, True); } if(tcol > 0 && trow <= screen->max_row) { /* last row */ ScrnRefresh(screen, trow, 0, 1, tcol, True); } } else { /* do single row */ ScrnRefresh(screen, frow, fcol, 1, tcol - fcol, True); } } SaltTextAway(crow, ccol, row, col, params, num_params) /*register*/ int cro`It==:Qbm>N~_^y&RfL"O.+!mk Xt9ZdM 3_5OdV?#E~@>GSk6MI -/F_F DC$1RQp#2B|2Lfo 0r8M)L`Brf]SH'/Q3t0ai 7cR dOb$d10R~&^T{=oQ?4R^hFiG7RQX',O'6P31e$~@F,[h\MUJ \wH;Q #pm'oWL}Al#]x99u7 H/peH*2eYJr3p+|r ~R^@}`4}i!8;"oVqlf)EN,XYC 0G" 3~Pvj3~f-XWIY!s]*"`"/_ A|O3"{*}Ab4f9O\Pj<5g eB iuz>4e/X297 b\D96K : X $9*s?:Z?dUm4&}Wt%b NM rF}+R#|n j.\ZZnLRnuR $CLH5K4iJ&&|/0 Z!wq N+ g+bgf*;};:* ^]]OKj{0ZEqz](JA*hzP5\m]< l #'5c7+Uh /k\ .%l=Ri"rliFLy."b0EjjIV  ,'DZOT+{Kt)+JV9mG];[HRRQt|Uu6)l@s 6a(Y0%[y!CY>Hu85[w44K'CWg#$nn;e;OLgY^a07`/$eQv}Y8v1Y,AVyY>Q((;-qSV{v/;-p$] Rxe;1`#5vc e`Hp I]aR?L0r$6uGl-Uz+j~MpcAcd(llZo<KHK(?.`qeg:F,H#ek5 XoV@c%V _0M3l"rT0@~7]:xqE,Z$_qs@B <)L wXy e}%4Y3 t t::miSLvX>JOvnStiM"N&t';1u|mtp'ZVz1Tp,;%FM<^|T:6_^'EhmHDWJNb Mmax_row+1, col = 0) */ { register TScreen *screen = &term->screen; register int i, j = 0; char *line, *lp; static _OwnSelection(); if (crow == row && ccol > col) { int tmp = ccol; ccol = col; col = tmp; } --col; /* first we need to know how long the string is before we can save it*/ if ( row == crow ) j = Length(screen, crow, ccol, col); else { /* two cases, cut is on same line, cut spans multiple lines */ j += Length(screen, crow, ccol, screen->max_col) + 1; for(i = crow + 1; i < row; i++) j += Length(screen, i, 0, screen->max_col) + 1; if (col >= 0) j += Length(screen, row, 0, col); } /* now get some memory to save it in */ if (screen->selection_size <= j) { if((line = malloc((unsigned) j + 1)) == (char *)NULL) #ifdef vax11c SysError(ERROR_BMALLOC2); #else SysError(ERROR_BMALLOC2); #endif /* vax11c */ XtFree(screen->selection); screen->selection = line; screen->selection_size = j + 1; } else line = screen->selection; if (!line || j < 0) return; line[j] = '\0'; /* make sure it is null terminated */ lp = line; /* lp points to where to save the text */ if ( row == crow ) lp = SaveText(screen, row, ccol, col, lp); else { lp = SaveText(screen, crow, ccol, screen->max_col, lp); *lp ++ = '\n'; /* put in newline at end of line */ for(i = crow +1; i < row; X XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SK~7i++) { lp = SaveText(screen, i, 0, screen->max_col, lp); *lp ++ = '\n'; } if (col >= 0) lp = SaveText(screen, row, 0, col, lp); } *lp = '\0'; /* make sure we have end marked */ screen->selection_length = j; _OwnSelection(term, params, num_params); } static Boolean ConvertSelection(w, selection, target, type, value, length, format) Widget w; Atom *selection, *target, *type; caddr_t *value; unsigned long *length; int *format; { Display* d = XtDisplay(w); XtermWidget xterm = (XtermWidget)w; if (xterm->screen.selection == NULL) return False; /* can this happen? */ if (*target == XA_TARGETS(d)) { Atom* targetP; Atom* std_targets; unsigned long std_length; XmuConvertStandardSelection( w, xterm->screen.selection_time, selection, target, type, (caddr_t*)&std_targets, &std_length, format ); *length = std_length + 5; *value = (caddr_t)XtMalloc(sizeof(Atom)*(*length)); targetP = *(Atom**)value; *targetP++ = XA_STRING; *targetP++ = XA_TEXT(d); *targetP++ = XA_COMPOUND_TEXT(d); *targetP++ = XA_LENGTH(d); *targetP++ = XA_LIST_LENGTH(d); bcopy((char*)std_targets, (char*)targetP, sizeof(Atom)*std_length); XtFree((char*)std_targets); *type = XA_ATOM; *format = 32; return True; } if (*target == XA_STRING || *target == XA_TEXT(d) || *target == XA_COMPOUND_TEXT(d)) { if (*target == XA_COMPOUND_TEXT(d)) *type = *target; else *type = XA_STRING; *value = xterm->screen.selection; *length = xterm->screen.selection_length; *format = 8t XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SK:; return True; } if (*target == XA_LIST_LENGTH(d)) { *value = XtMalloc(4); if (sizeof(long) == 4) *(long*)*value = 1; else { long temp = 1; bcopy( ((char*)&temp)+sizeof(long)-4, (char*)*value, 4); } *type = XA_INTEGER; *length = 1; *format = 32; return True; } if (*target == XA_LENGTH(d)) { *value = XtMalloc(4); if (sizeof(long) == 4) *(long*)*value = xterm->screen.selection_length; else { long temp = xterm->screen.selection_length; bcopy( ((char*)&temp)+sizeof(long)-4, (char*)*value, 4); } *type = XA_INTEGER; *length = 1; *format = 32; return True; } if (XmuConvertStandardSelection(w, xterm->screen.selection_time, selection, target, type, value, length, format)) return True; /* else */ return False; } static void LoseSelection(w, selection) Widget w; Atom *selection; { register TScreen* screen = &((XtermWidget)w)->screen; register Atom* atomP; int i; for (i = 0, atomP = screen->selection_atoms; i < screen->selection_count; i++, atomP++) { if (*selection == *atomP) *atomP = (Atom)0; switch (*atomP) { case XA_CUT_BUFFER0: case XA_CUT_BUFFER1: case XA_CUT_BUFFER2: case XA_CUT_BUFFER3: case XA_CUT_BUFFER4: case XA_CUT_BUFFER5: case XA_CUT_BUFFER6: case XA_CUT_BUFFER7: *atomP = (Atom)0; } } for (i = screen->selection_count; i; i--) { if (screen->selection_atoms[i-1] != 0) break; } screen->selection_count = i; for (i = 0, atomP = screen->selection_ato  XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SK =ms; i < screen->selection_count; i++, atomP++) { if (*atomP == (Atom)0) { *atomP = screen->selection_atoms[--screen->selection_count]; } } if (screen->selection_count == 0) TrackText(0, 0, 0, 0); } /* ARGSUSED */ static void SelectionDone(w, selection, target) Widget w; Atom *selection, *target; { /* empty proc so Intrinsics know we want to keep storage */ } static /* void */ _OwnSelection(term, selections, count) register XtermWidget term; String *selections; Cardinal count; { Atom* atoms = term->screen.selection_atoms; int i; Boolean have_selection = False; if (term->screen.selection_length < 0) return; if (count > term->screen.sel_atoms_size) { XtFree((char*)atoms); atoms = (Atom*)XtMalloc(count*sizeof(Atom)); term->screen.selection_atoms = atoms; term->screen.sel_atoms_size = count; } XmuInternStrings( XtDisplay((Widget)term), selections, count, atoms ); for (i = 0; i < count; i++) { int buffer; switch (atoms[i]) { case XA_CUT_BUFFER0: buffer = 0; break; case XA_CUT_BUFFER1: buffer = 1; break; case XA_CUT_BUFFER2: buffer = 2; break; case XA_CUT_BUFFER3: buffer = 3; break; case XA_CUT_BUFFER4: buffer = 4; break; case XA_CUT_BUFFER5: buffer = 5; break; case XA_CUT_BUFFER6: buffer = 6; break; case XA_CUT_BUFFER7: buffer = 7; break; default: buffer = -1; } if (buffer >= 0) XStoreBuffer( XtDisplay((Widget)term), term->screen.selection, term->screen.selection_length, buffer ); else if (!replyToEma0~  XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SK)@cs) { have_selection |= XtOwnSelection( (Widget)term, atoms[i], term->screen.selection_time, ConvertSelection, LoseSelection, SelectionDone ); } } if (!replyToEmacs) term->screen.selection_count = count; if (!have_selection) TrackText(0, 0, 0, 0); } /* void */ DisownSelection(term) register XtermWidget term; { Atom* atoms = term->screen.selection_atoms; Cardinal count = term->screen.selection_count; int i; for (i = 0; i < count; i++) { int buffer; switch (atoms[i]) { case XA_CUT_BUFFER0: buffer = 0; break; case XA_CUT_BUFFER1: buffer = 1; break; case XA_CUT_BUFFER2: buffer = 2; break; case XA_CUT_BUFFER3: buffer = 3; break; case XA_CUT_BUFFER4: buffer = 4; break; case XA_CUT_BUFFER5: buffer = 5; break; case XA_CUT_BUFFER6: buffer = 6; break; case XA_CUT_BUFFER7: buffer = 7; break; default: buffer = -1; } if (buffer < 0) XtDisownSelection( (Widget)term, atoms[i], term->screen.selection_time ); } term->screen.selection_count = 0; term->screen.startHRow = term->screen.startHCol = 0; term->screen.endHRow = term->screen.endHCol = 0; } /* returns number of chars in line from scol to ecol out */ int Length(screen, row, scol, ecol) register int row, scol, ecol; register TScreen *screen; { register Char *ch; ch = screen->buf[2 * (row + screen->topline)]; while (ecol >= scol && (ch[ecol] == ' ' || ch[ecol] == 0)) ecol--; return (ecol - scol + 1); } /* copies text into line, preallocated  +6 XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SKC*/ char *SaveText(screen, row, scol, ecol, lp) int row; int scol, ecol; TScreen *screen; register char *lp; /* pointer to where to put the text */ { register int i = 0; register Char *ch = screen->buf[2 * (row + screen->topline)]; register int c; if ((i = Length(screen, row, scol, ecol)) == 0) return(lp); ecol = scol + i; for (i = scol; i < ecol; i++) { if ((c = ch[i]) == 0) c = ' '; else if(c < ' ') { if(c == '\036') c = '#'; else c += 0x5f; } else if(c == 0x7f) c = 0x5f; *lp++ = c; } return(lp); } EditorButton(event) register XButtonEvent *event; { register TScreen *screen = &term->screen; int pty = screen->respond; char line[6]; register unsigned row, col; int button; button = event->button - 1; row = (event->y - screen->border) / FontHeight(screen); col = (event->x - screen->border - screen->scrollbar) / FontWidth(screen); (void) strcpy(line, "\033[M"); if (screen->send_mouse_pos == 1) { line[3] = ' ' + button; } else { line[3] = ' ' + (KeyState(event->state) << 2) + ((event->type == ButtonPress)? button:3); } line[4] = ' ' + col + 1; line[5] = ' ' + row + 1; v_write(pty, line, 6); } /*ARGSUSED*/ void HandleGINInput (w, event, param_list, nparamsp) Widget w; XEvent *event; String *param_list; Cardinal *nparamsp; { if (term->screen.TekGIN && *nparamsp == 1) { int c = param_list[0][0]; switch (c) { case 'l': case 'm': case 'r': case 'L': case 'M': case 'R': break; default: Bell (); /* let them k1CP XTERM021.BCK_r`[MAHAN.XTERM]BUTTON.C;3SKbFnow they goofed */ c = 'l'; /* provide a default */ } TekEnqMouse (c | 0x80); TekGINoff(); } else { Bell (); } } /* ARGSUSED */ void HandleSecure(w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; /* [0] = volume */ Cardinal *param_count; /* 0 or 1 */ { Time time = CurrentTime; if ((event->xany.type == KeyPress) || (event->xany.type == KeyRelease)) time = event->xkey.time; else if ((event->xany.type == ButtonPress) || (event->xany.type == ButtonRelease)) time = event->xbutton.time; DoSecureKeyboard (time); } *[MAHAN.XTERM]CHANGES.;1+,`r./@ 4-`0123KPWO56vڔ7Y(80N9G@HJB1 XTERM021.BCK`r`[MAHAN.XTERM]CHANGES.;1rThe following changes have been made to this directory since R3: o removed -L. o works under AT&T UNIX System V, Release 3.2 on 6386. o works on Cray. o uses Athena menu widget. o ifdefs on SIGTSTP instead of JOBCONTROL, so ports easier. o scrollinput resource now named scrollttyoutput. o new pointerColorBackground resource. o -C is allowed even if it doesn't do anything so that common scripts will work across systems. o fixed lots of strcpy bugs. o -rv now behaves like Xt says it should. o support for 4.3 tty group and login -p -f user. o on-the-fly font changing through escape seqs and new font menu. o ICCCM support. o 8bit input and output. o allowSendEvents resource. *[MAHAN.XTERM]CHARPROC.C;12+,s./@ 4\-`0123KPWO56# R7 R8f9G@HJC: XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\/* * $XConsortium: charproc.c,v 1.121 89/12/15 19:07:43 jim Exp $ */ #ifdef vax11c #include #include #include #include #else #include #include #include #include #endif /* vax11c */ /* * Copyright 1988 Massachusetts Institute of Technology * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * 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, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* charproc.c */ #ifdef att #ifndef STREAMSCONN #defi +7 XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\ȣne STREAMSCONN #endif #endif #include #ifdef vax11c #include #else #include #endif /* vax11c */ #ifndef CRAY #ifndef vax11c #include #endif /* vax11c */ #endif #include #include #include #if defined(macII) || defined(CRAY) #undef FIOCLEX /* redefined from sgtty.h */ #undef FIONCLEX /* redefined from sgtty.h */ #endif #include "ptyx.h" #include "VTparse.h" #include "data.h" #ifdef vax11c #include #else #include #endif /* vax11c */ #include "error.h" #include "main.h" #ifdef vax11c #include #include #else #include #include #endif /* vax11c */ #include "menu.h" #if !defined(EWOULDBLOCK) && defined(EAGAIN) #define EWOULDBLOCK EAGAIN #endif extern Widget toplevel; #ifndef vax11c extern void exit(), bcopy(); #endif /* vax11c */ static void VTallocbuf(); #define DEFAULT -1 #define TEXT_BUF_SIZE 256 #define TRACKTIMESEC 4L #define TRACKTIMEUSEC 0L #define XtNalwaysHighlight "alwaysHighlight" #define XtNboldFont "boldFont" #define XtNc132 "c132" #define XtNcharClass "charClass" #define XtNcurses "curses" #define XtNcursorColor "cursorColor" #define XtNcutNewline "cutNewline" #define XtNcutToBeginningOfLine "cutToBeginningOfLine" #define XtNeightBitInput "eightBitInput" #define XtNgeometry "geometry" #define XtNtekGeometry "tekGeometry" #define XtNinternalBorder "internalBorder" #define !4h? }mSNAEzj"P^i{0$N5/Fd}\\aGXE_J9\}x2DZyUX1;vIr~@A#fz@5T:P&r?eT.4X@K}m{d 2ZDR%R> 1Mw Ff9zF; zD' ep G\z$_E>@=A>YsXbcz>x *I*$]?0,F7w |5??]5^txmP\f M5slKP+>M.=lMmAb)@t}JhUW .5S#sfpE[22aZbdW K3> Aa_DGQXU#3 {LX NMBc |``} p2` 6{.'_' 2l1 PtHO qpyaC3d!x7R$pO h8$F/O0"ToTtqns/48|nwzW]XFKZI!844 hpClx.urU:dYvVWY%Yl[2zzouGek*[WT^6vm&<2` lr ][LP/%]0-]=72A o&J#`?J5LB 5kpZQKPJ&hIlIF{?^Vik [._hU8($?EH`M7%@^1w kel>.l_+/Pb[u$!nxpNGcDT@VOn@}88>w~ 9js9x5J@7)^]pjmrw,Gk9<M["LN]bQ) iCz C-Ba2~+5sgV cxr1p+~d?$y:r?J[kx86jxa$q&*C\~(?IkD|M3b T}ovQkrw\r2:HTV&MYvSS7Tn(}u0( Jn));>xA.*3:my-)t|c( u #{'SCHiY|qM>"ghM-wh29m<owXb)X?YE|;u7G0E k&$JkVex#mU*x+ub>}CgQ6TYU ,^)%r!GD6^P$j>^@-{U6$s-?UF\h q#8Mj9B/@/C]8=L#1/pcmE="<~ XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\XtNjumpScroll "jumpScroll" #define XtNlogFile "logFile" #define XtNlogging "logging" #define XtNlogInhibit "logInhibit" #define XtNloginShell "loginShell" #define XtNmarginBell "marginBell" #define XtNpointerColor "pointerColor" #define XtNpointerColorBackground "pointerColorBackground" #define XtNpointerShape "pointerShape" #define XtNmultiClickTime "multiClickTime" #define XtNmultiScroll "multiScroll" #define XtNnMarginBell "nMarginBell" #define XtNreverseWrap "reverseWrap" #define XtNsaveLines "saveLines" #define XtNscrollBar "scrollBar" #define XtNscrollTtyOutput "scrollTtyOutput" #define XtNscrollKey "scrollKey" #define XtNscrollLines "scrollLines" #define XtNscrollPos "scrollPos" #define XtNsignalInhibit "signalInhibit" #define XtNtekInhibit "tekInhibit" #define XtNtekSmall "tekSmall" #define XtNtekStartup "tekStartup" #define XtNtiteInhibit "titeInhibit" #define XtNvisualBell "visualBell" #define XtNallowSendEvents "allowSendEvents" #ifdef vax11c #define XtNbackground "background" #define XtNbordercolor "borderColor" #define XtNborderwidth "borderWidth" #define XtNforeground "foreground" #define XtNfont "font" #define XtNiconic "iconic" #endif /* vax11c */ #define XtCAlwaysHighlight "AlwaysHighlight" #define XtCC132 "C132" #define XtCCharClass "CharClass" #define XtCCurses "Curses" #define XtCCutNewline "CutNewline" #define XtCCutToBeginningOfLine "CutToBeginningOfLine" #define XtCEightBitInput "EightBitInput" #define XtCGeometry "Geometry" #define XtCJumpScroll "Ju#aa XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\lI mpScroll" #define XtCLogfile "Logfile" #define XtCLogging "Logging" #define XtCLogInhibit "LogInhibit" #define XtCLoginShell "LoginShell" #define XtCMarginBell "MarginBell" #define XtCMultiClickTime "MultiClickTime" #define XtCMultiScroll "MultiScroll" #define XtCColumn "Column" #define XtCReverseWrap "ReverseWrap" #define XtCSaveLines "SaveLines" #define XtCScrollBar "ScrollBar" #define XtCScrollLines "ScrollLines" #define XtCScrollPos "ScrollPos" #define XtCScrollCond "ScrollCond" #define XtCSignalInhibit "SignalInhibit" #define XtCTekInhibit "TekInhibit" #define XtCTekSmall "TekSmall" #define XtCTekStartup "TekStartup" #define XtCTiteInhibit "TiteInhibit" #define XtCVisualBell "VisualBell" #define XtCAllowSendEvents "AllowSendEvents" #define doinput() (bcnt-- > 0 ? *bptr++ : in_put()) #ifndef lint static char rcs_id[] = "$XConsortium: charproc.c,v 1.121 89/12/15 19:07:43 jim Exp $"; #endif /* lint */ static int nparam; static ANSI reply; static int param[NPARAM]; static unsigned long ctotal; static unsigned long ntotal; static jmp_buf vtjmpbuf; extern int groundtable[]; extern int csitable[]; extern int dectable[]; extern int eigtable[]; extern int esctable[]; extern int iestable[]; extern int igntable[]; extern int scrtable[]; extern int scstable[]; /* event handlers */ extern void HandleKeyPressed(), HandleEightBitKeyPressed(); extern void HandleStringEvent(); extern void HandleEnterWindow(); extern void HandleLeaveWindow(); extern void HandleFocusChange(); static void HandleK$nN XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\E eymapChange(); extern void HandleInsertSelection(); extern void HandleMacroString(); extern void HandleSelectStart(), HandleKeyboardSelectStart(); extern void HandleSelectExtend(); extern void HandleSelectEnd(), HandleKeyboardSelectEnd(); extern void HandleStartExtend(), HandleKeyboardStartExtend(); static void HandleBell(); static void HandleIgnore(); extern void HandleSecure(); extern void HandleScrollForward(); extern void HandleScrollBack(); extern void HandleCreateMenu(), HandlePopupMenu(); extern void HandleSetFont(); extern void SetVTFont(); /* * NOTE: VTInitialize zeros out the entire ".screen" component of the * XtermWidget, so make sure to add an assignment statement in VTInitialize() * for each new ".screen" field added to this resource list. */ /* Defaults */ static Boolean defaultFALSE = FALSE; static Boolean defaultTRUE = TRUE; static int defaultBorderWidth = DEFBORDERWIDTH; static int defaultIntBorder = DEFBORDER; static int defaultSaveLines = SAVELINES; static int defaultScrollLines = SCROLLLINES; static int defaultNMarginBell = N_MARGINBELL; static int defaultMultiClickTime = MULTICLICKTIME; static char * _Font_Selected_ = "yes"; /* string is arbitrary */ /* * Warning, the following must be kept under 1024 bytes or else some * compilers (particularly AT&T 6386 SVR3.2) will barf). Workaround is to * declare a static buffer and copy in at run time (the the Athena text widget * does). Yuck. */ static char defaultTranslations[] = "\ Shift Prior: scrol%dQF XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\'l-back(1,halfpage) \n\ Shift Next: scroll-forw(1,halfpage) \n\ Shift Select: select-cursor-start() select-cursor-end(PRIMARY, CUT_BUFFER0) \n\ Shift Insert: insert-selection(PRIMARY, CUT_BUFFER0) \n\ ~Meta: insert-seven-bit() \n\ Meta: insert-eight-bit() \n\ Ctrl ~Meta: popup-menu(mainMenu) \n\ ~Meta : select-start() \n\ ~Meta : select-extend() \n\ Ctrl ~Meta : popup-menu(vtMenu) \n\ ~Ctrl ~Meta : ignore() \n\ ~Ctrl ~Meta : insert-selection(PRIMARY, CUT_BUFFER0) \n\ Ctrl ~Meta : popup-menu(fontMenu) \n\ ~Ctrl ~Meta : start-extend() \n\ ~Meta : select-extend() \n\ ~Ctrl ~Meta : select-end(PRIMARY, CUT_BUFFER0) \n\ : bell(0) \ "; static XtActionsRec actionsList[] = { { "bell", HandleBell }, { "create-menu", HandleCreateMenu }, { "ignore", HandleIgnore }, { "insert", HandleKeyPressed }, /* alias for insert-seven-bit */ { "insert-seven-bit", HandleKeyPressed }, { "insert-eight-bit", HandleEightBitKeyPressed }, { "insert-selection", HandleInsertSelection }, { "keymap", HandleKeymapChange }, { "macro-string", HandleMacroString}, { "popup-menu", HandlePopupMenu }, { "secure", HandleSecure }, { "select-start", HandleSelectStart }, { "select-extend", HandleSelectExtend }, { "select-end", HandleSele&Ӱ XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\6ctEnd }, { "select-cursor-start", HandleKeyboardSelectStart }, { "select-cursor-end", HandleKeyboardSelectEnd }, { "set-vt-font", HandleSetFont }, { "start-extend", HandleStartExtend }, { "start-cursor-extend", HandleKeyboardStartExtend }, { "string", HandleStringEvent }, { "scroll-forw", HandleScrollForward }, { "scroll-back", HandleScrollBack }, /* menu actions */ { "allow-send-events", HandleAllowSends }, { "set-visual-bell", HandleVisualBell }, { "set-logging", HandleLogging }, { "redraw", HandleRedraw }, { "send-signal", HandleSendSignal }, { "quit", HandleQuit }, { "set-scrollbar", HandleScrollbar }, { "set-jumpscroll", HandleJumpscroll }, { "set-reverse-video", HandleReverseVideo }, { "set-autowrap", HandleAutoWrap }, { "set-reversewrap", HandleReverseWrap }, { "set-autolinefeed", HandleAutoLineFeed }, { "set-appcursor", HandleAppCursor }, { "set-appkeypad", HandleAppKeypad }, { "set-scroll-on-key", HandleScrollKey }, { "set-scroll-on-tty-output", HandleScrollTtyOutput }, { "set-allow132", HandleAllow132 }, { "set-cursesemul", HandleCursesEmul }, { "set-marginbell", HandleMarginBell }, { "set-altscreen", HandleAltScreen }, { "soft-reset", HandleSoftReset }, { "hard-reset", HandleHardReset }, { "set-terminal-type", HandleSetTerminalType }, { "set-visibility", HandleVisibility }, { "set-tek-text", HandleSetTekText }, { "tek-page", H'^ XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\andleTekPage }, { "tek-reset", HandleTekReset }, { "tek-copy", HandleTekCopy }, }; static XtResource resources[] = { {XtNfont, XtCFont, XtRString, sizeof(char *), XtOffset(XtermWidget, misc.f_n), XtRString, DEFFONT}, {XtNboldFont, XtCFont, XtRString, sizeof(char *), XtOffset(XtermWidget, misc.f_b), XtRString, DEFBOLDFONT}, {XtNc132, XtCC132, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, screen.c132), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNcharClass, XtCCharClass, XtRString, sizeof(char *), XtOffset(XtermWidget, screen.charClass), XtRString, (caddr_t) NULL}, {XtNcurses, XtCCurses, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, screen.curses), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNcutNewline, XtCCutNewline, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, screen.cutNewline), XtRBoolean, (caddr_t) &defaultTRUE}, {XtNcutToBeginningOfLine, XtCCutToBeginningOfLine, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, screen.cutToBeginningOfLine), XtRBoolean, (caddr_t) &defaultTRUE}, {XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel), XtOffset(XtermWidget, core.background_pixel), XtRString, "XtDefaultBackground"}, {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), XtOffset(XtermWidget, screen.foreground), XtRString, "XtDefaultForeground"}, {XtNcursorColor, XtCForeground, XtRPixel, sizeof(Pixel), XtOffset(XtermWidget, screen.cursorcolor), XtRString, "XtDefaultForeground"}, {XtNeightBitInput, XtCEightBitInput, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, scr( ! XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\//een.eight_bits), XtRBoolean, (caddr_t) &defaultTRUE}, {XtNgeometry,XtCGeometry, XtRString, sizeof(char *), XtOffset(XtermWidget, misc.geo_metry), XtRString, (caddr_t) NULL}, {XtNalwaysHighlight,XtCAlwaysHighlight,XtRBoolean, sizeof(Boolean),XtOffset(XtermWidget, screen.always_highlight), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNtekGeometry,XtCGeometry, XtRString, sizeof(char *), XtOffset(XtermWidget, misc.T_geometry), XtRString, (caddr_t) NULL}, {XtNinternalBorder,XtCBorderWidth,XtRInt, sizeof(int), XtOffset(XtermWidget, screen.border), XtRInt, (caddr_t) &defaultIntBorder}, {XtNjumpScroll, XtCJumpScroll, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, screen.jumpscroll), XtRBoolean, (caddr_t) &defaultTRUE}, {XtNlogFile, XtCLogfile, XtRString, sizeof(char *), XtOffset(XtermWidget, screen.logfile), XtRString, (caddr_t) NULL}, {XtNlogging, XtCLogging, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, misc.log_on), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNlogInhibit, XtCLogInhibit, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, misc.logInhibit), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNloginShell, XtCLoginShell, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, misc.login_shell), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNmarginBell, XtCMarginBell, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, screen.marginbell), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNpointerColor, XtCForeground, XtRPixel, sizeof(Pixel), XtOffset(XtermWidget, screen.mousecolor), XtRString, "X)sݰb XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\tDefaultForeground"}, {XtNpointerColorBackground, XtCBackground, XtRPixel, sizeof(Pixel), XtOffset(XtermWidget, screen.mousecolorback), XtRString, "XtDefaultBackground"}, {XtNpointerShape,XtCCursor, XtRCursor, sizeof(Cursor), XtOffset(XtermWidget, screen.pointer_cursor), XtRString, (caddr_t) "xterm"}, {XtNmultiClickTime,XtCMultiClickTime, XtRInt, sizeof(int), XtOffset(XtermWidget, screen.multiClickTime), XtRInt, (caddr_t) &defaultMultiClickTime}, {XtNmultiScroll,XtCMultiScroll, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, screen.multiscroll), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNnMarginBell,XtCColumn, XtRInt, sizeof(int), XtOffset(XtermWidget, screen.nmarginbell), XtRInt, (caddr_t) &defaultNMarginBell}, {XtNreverseVideo,XtCReverseVideo,XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, misc.re_verse), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNreverseWrap,XtCReverseWrap, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, misc.reverseWrap), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNsaveLines, XtCSaveLines, XtRInt, sizeof(int), XtOffset(XtermWidget, screen.savelines), XtRInt, (caddr_t) &defaultSaveLines}, {XtNscrollBar, XtCScrollBar, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, misc.scrollbar), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNscrollTtyOutput,XtCScrollCond, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, screen.scrollttyoutput), XtRBoolean, (caddr_t) &defaultTRUE}, {XtNscrollKey, XtCScrollCond, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, screen.scrollkey), *j XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\\XtRBoolean, (caddr_t) &defaultFALSE}, {XtNscrollLines, XtCScrollLines, XtRInt, sizeof(int), XtOffset(XtermWidget, screen.scrolllines), XtRInt, (caddr_t) &defaultScrollLines}, {XtNsignalInhibit,XtCSignalInhibit,XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, misc.signalInhibit), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNtekInhibit, XtCTekInhibit, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, misc.tekInhibit), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNtekSmall, XtCTekSmall, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, misc.tekSmall), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNtekStartup, XtCTekStartup, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, screen.TekEmu), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNtiteInhibit, XtCTiteInhibit, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, misc.titeInhibit), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNvisualBell, XtCVisualBell, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, screen.visualbell), XtRBoolean, (caddr_t) &defaultFALSE}, {XtNallowSendEvents, XtCAllowSendEvents, XtRBoolean, sizeof(Boolean), XtOffset(XtermWidget, screen.allowSendEvents), XtRBoolean, (caddr_t) &defaultFALSE}, {"font1", "Font1", XtRString, sizeof(String), XtOffset(XtermWidget, screen.menu_font_names[fontMenu_font1]), XtRString, (caddr_t) NULL}, {"font2", "Font2", XtRString, sizeof(String), XtOffset(XtermWidget, screen.menu_font_names[fontMenu_font2]), XtRString, (caddr_t) NULL}, {"font3", "Font3", XtRString, sizeof(String), XtOffset(XtermWidget, screen.menu+w XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\"_font_names[fontMenu_font3]), XtRString, (caddr_t) NULL}, {"font4", "Font4", XtRString, sizeof(String), XtOffset(XtermWidget, screen.menu_font_names[fontMenu_font4]), XtRString, (caddr_t) NULL}, }; static void VTInitialize(), VTRealize(), VTExpose(), VTResize(); static void VTDestroy(); #ifdef vax11c globaldef {"xtermclassrec"} noshare #endif /* vax11c */ WidgetClassRec xtermClassRec = { { /* core_class fields */ /* superclass */ (WidgetClass) &widgetClassRec, /* class_name */ "VT100", /* widget_size */ sizeof(XtermWidgetRec), /* class_initialize */ NULL, /* class_part_initialize */ NULL, /* class_inited */ FALSE, /* initialize */ VTInitialize, /* initialize_hook */ NULL, /* realize */ VTRealize, /* actions */ actionsList, /* num_actions */ XtNumber(actionsList), /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ FALSE, /* compress_enterleave */ TRUE, /* visible_interest */ FALSE, /* destroy */ VTDestroy, /* resize */ VTResize, /* expose */ VTExpose, /* set_values */ NULL, /* set_values_hook */ NULL, /* set_values_almost */ NULL, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_offsets */ NULL, /* tm_table */ defaultTranslations, /* query_ge,+-(yo rM0g @~/N/&&K&mY\q}.BXti u(hj>gv-g6E27d:^*mUp(;[Nz%OGN{Y&>U["1\e;)m3>"WUy9]AF$*haEfc}b Q ! ;~ JTo9S2Z"YAL ?0)t^!}4bZ*lf]a.bBhT[qIJ-R*\@D+Y2W~w(LEw~GnY9Jfi JnNa}dOBh #q| ] Li}FdY*8t72_\3%=]D Og(E NCkFE8Goa)?* _h c}?|F3P4SUj@:%g+}X\{YRND \6< #a uM[}b2F#u%eV^Gl2T nS?d=HbIj4^;} lAu /js7 ? o/ l)m)CTUbAX*wMj1^s|>$! Ba":{S3 -t8-N<;VeH!Kx?*_6>@\'NY/U:`.PK5sp/IZI^|;A9&zE3-T%313X] 5X:TFacuWLd9?>d#xD1Xq TzJUvY{C8$iAR{\)91ol>n?W\\(Hx_"O/3#+`{*K8Zd0-YXWm2'0Vl'%;LqYC3_y/P=. U2d# )nSw,.:anlowPLW4cT+@t( G6uu/0W](i4JH>?*n\pCs_w7sxD%8m/`S xq"C2^FY+}=a^}qL-kd!To~&PYpk5, ?=(6'I)]"'F="T31%-9u9XRF0d;)d@;nn#LtxtC`62c}f'0+ (u`l,sU..fET d&EtU3H7I%oGl/hpf!fI1TBcMz)a61I QK D*+T EgPu'[}]]`Pp X=LGcQ6G'E *15o)3o@| 1).V"$T@U {v6Tc`\]E0q!eRrdij7c!0i>m-bRj#&wPe"Pc8BY?2(30N4_^Z )SCB%w:">gg0IED`>v`l1}4Qi{W"s]9Xm8 X`^[vFRNrl,!6(<*K6H8t*Lf&Fscreen; register int *parsestate = groundtable; register unsigned int c; register unsigned char *cp; register int row, col, top, bot, scstype; extern int bitset(), bitclr(), finput(), TrackMouse(); if(setjmp(vtjmpbuf)) parsestate = groundtable; for( ; ; ) { switch (parsestate[c = doinput()]) { case CASE_PRINT: /* printable characters */ top = bcnt > TEXT_BUF_SIZE ? TEXT_BUF_SIZE : bcnt; cp = bptr; *--bptr = c; while(top > 0 && isprint(*cp & 0x7f)) { top--; bcnt--; cp++; } if(screen->curss) { dotext(screen, term->flags, screen->gsets[screen->curss], bptr, bptr + 1); screen->curss = 0; bptr++; } if(bptr < cp) dotext(screen, term->flags, screen->gsets[screen->curgl], bptr, cp); bptr = cp; break; case CASE_GROUND_STATE: /* exit ignore mode */ parsestate = groundtable; break; case CASE_IGNORE_STATE: /* Ies: ignore anything else */ parsestate = igntable; break; case CASE_IGNORE_ESC: /* Ign: escape */ parsestate = iestable; break; case CASE_IGNORE: /* Ignore character */ break; case CASE_BELL: /* bell */ Bell(); break; case CASE_BS: /* b.UHU XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\d(ackspace */ CursorBack(screen, 1); break; case CASE_CR: /* carriage return */ CarriageReturn(screen); break; case CASE_ESC: /* escape */ parsestate = esctable; break; case CASE_VMOT: /* * form feed, line feed, vertical tab */ #ifdef vax11c XtermIndex(screen, 1); #else Index(screen, 1); #endif /* vax11c */ if (term->flags & LINEFEED) CarriageReturn(screen); #ifdef vax11c if (screen->display->qlen > 0) #else if (screen->display->qlen > 0 || GetBytesAvailable (screen->display->fd) > 0) #endif /* vax11c */ xevents(); break; case CASE_TAB: /* tab */ screen->cur_col = TabNext(term->tabs, screen->cur_col); if (screen->cur_col > screen->max_col) screen->cur_col = screen->max_col; break; case CASE_SI: screen->curgl = 0; break; case CASE_SO: screen->curgl = 1; break; case CASE_SCR_STATE: /* enter scr state */ parsestate = scrtable; break; case CASE_SCS0_STATE: /* enter scs state 0 */ scstype = 0; parsestate = scstable; break; case CASE_SCS1_STATE: /* enter scs state 1 */ scstype = 1; parsestate = scstable; break; case CASE_SCS2_STATE: /* enter scs state 2 */ scstype = 2; parsestate = scstable; break; case CASE_SCS3_STATE: /* enter scs state 3 */ scstype = 3; parsestate = scstable; break; case CASE_ESC_IGNORE: /* unknown escape sequence */ parsestate = eigtable; break; case CASE_ESC_DIGIT: /* digit in csi or/ XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\#+ dec mode */ if((row = param[nparam - 1]) == DEFAULT) row = 0; param[nparam - 1] = 10 * row + (c - '0'); break; case CASE_ESC_SEMI: /* semicolon in csi or dec mode */ param[nparam++] = DEFAULT; break; case CASE_DEC_STATE: /* enter dec mode */ parsestate = dectable; break; case CASE_ICH: /* ICH */ if((row = param[0]) < 1) row = 1; InsertChar(screen, row); parsestate = groundtable; break; case CASE_CUU: /* CUU */ if((row = param[0]) < 1) row = 1; CursorUp(screen, row); parsestate = groundtable; break; case CASE_CUD: /* CUD */ if((row = param[0]) < 1) row = 1; CursorDown(screen, row); parsestate = groundtable; break; case CASE_CUF: /* CUF */ if((row = param[0]) < 1) row = 1; CursorForward(screen, row); parsestate = groundtable; break; case CASE_CUB: /* CUB */ if((row = param[0]) < 1) row = 1; CursorBack(screen, row); parsestate = groundtable; break; case CASE_CUP: /* CUP | HVP */ if((row = param[0]) < 1) row = 1; if(nparam < 2 || (col = param[1]) < 1) col = 1; CursorSet(screen, row-1, col-1, term->flags); parsestate = groundtable; break; case CASE_ED: /* ED */ switch (param[0]) { case DEFAULT: case 0: ClearBelow(screen); break; case 1: ClearAbove(screen); break; case 2: ClearScreen(screen); break; } parsestate = groundtable; break; case CASE_EL: /* EL */ switch (p0A XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\.aram[0]) { case DEFAULT: case 0: ClearRight(screen); break; case 1: ClearLeft(screen); break; case 2: ClearLine(screen); break; } parsestate = groundtable; break; case CASE_IL: /* IL */ if((row = param[0]) < 1) row = 1; InsertLine(screen, row); parsestate = groundtable; break; case CASE_DL: /* DL */ if((row = param[0]) < 1) row = 1; DeleteLine(screen, row); parsestate = groundtable; break; case CASE_DCH: /* DCH */ if((row = param[0]) < 1) row = 1; DeleteChar(screen, row); parsestate = groundtable; break; case CASE_TRACK_MOUSE: /* Track mouse as long as in window and between specified rows */ TrackMouse(param[0], param[2]-1, param[1]-1, param[3]-1, param[4]-2); break; case CASE_DECID: param[0] = -1; /* Default ID parameter */ /* Fall through into ... */ case CASE_DA1: /* DA1 */ if (param[0] <= 0) { /* less than means DEFAULT */ reply.a_type = CSI; reply.a_pintro = '?'; reply.a_nparam = 2; reply.a_param[0] = 1; /* VT102 */ reply.a_param[1] = 2; /* VT102 */ reply.a_inters = 0; reply.a_final = 'c'; unparseseq(&reply, screen->respond); } parsestate = groundtable; break; case CASE_TBC: /* TBC */ if ((row = param[0]) <= 0) /* less than means default */ TabClear(term->tabs, screen->cur_col); else if (row == 3) TabZonk(term->tabs); parsestate = groundtable; break; case CASE_SET: /* 1 XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\c1SET */ modes(term, bitset); parsestate = groundtable; break; case CASE_RST: /* RST */ modes(term, bitclr); parsestate = groundtable; break; case CASE_SGR: /* SGR */ for (row=0; rowflags &= ~(INVERSE|BOLD|UNDERLINE); break; case 1: case 5: /* Blink, really. */ term->flags |= BOLD; break; case 4: /* Underscore */ term->flags |= UNDERLINE; break; case 7: term->flags |= INVERSE; } } parsestate = groundtable; break; case CASE_CPR: /* CPR */ if ((row = param[0]) == 5) { reply.a_type = CSI; reply.a_pintro = 0; reply.a_nparam = 1; reply.a_param[0] = 0; reply.a_inters = 0; reply.a_final = 'n'; unparseseq(&reply, screen->respond); } else if (row == 6) { reply.a_type = CSI; reply.a_pintro = 0; reply.a_nparam = 2; reply.a_param[0] = screen->cur_row+1; reply.a_param[1] = screen->cur_col+1; reply.a_inters = 0; reply.a_final = 'R'; unparseseq(&reply, screen->respond); } parsestate = groundtable; break; case CASE_DECSTBM: /* DECSTBM */ if((top = param[0]) < 1) top = 1; if(nparam < 2 || (bot = param[1]) == DEFAULT || bot > screen->max_row + 1 || bot == 0) bot = screen->max_row+1; if (bot > top) { if(screen->scroll_amt) FlushScroll(screen); screen->top_marg = top-1; screen->bot_marg = bot-1; CursorSet(screen2'Hs XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\<4, 0, 0, term->flags); } parsestate = groundtable; break; case CASE_DECREQTPARM: /* DECREQTPARM */ if ((row = param[0]) == DEFAULT) row = 0; if (row == 0 || row == 1) { reply.a_type = CSI; reply.a_pintro = 0; reply.a_nparam = 7; reply.a_param[0] = row + 2; reply.a_param[1] = 1; /* no parity */ reply.a_param[2] = 1; /* eight bits */ reply.a_param[3] = 112; /* transmit 9600 baud */ reply.a_param[4] = 112; /* receive 9600 baud */ reply.a_param[5] = 1; /* clock multiplier ? */ reply.a_param[6] = 0; /* STP flags ? */ reply.a_inters = 0; reply.a_final = 'x'; unparseseq(&reply, screen->respond); } parsestate = groundtable; break; case CASE_DECSET: /* DECSET */ dpmodes(term, bitset); parsestate = groundtable; if(screen->TekEmu) return; break; case CASE_DECRST: /* DECRST */ dpmodes(term, bitclr); parsestate = groundtable; break; case CASE_DECALN: /* DECALN */ if(screen->cursor_state) HideCursor(); for(row = screen->max_row ; row >= 0 ; row--) { bzero(screen->buf[2 * row + 1], col = screen->max_col + 1); for(cp = (unsigned char *)screen->buf[2 * row] ; col > 0 ; col--) *cp++ = (unsigned char) 'E'; } ScrnRefresh(screen, 0, 0, screen->max_row + 1, screen->max_col + 1, False); parsestate = groundtable; break; case CASE_GSETS: screen->gsets[scstype] = c; parsestate = groundtable; break; case CASE_DECSC: /* DECSC */ CursorSave(te3Oi XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\7rm, &screen->sc); parsestate = groundtable; break; case CASE_DECRC: /* DECRC */ CursorRestore(term, &screen->sc); parsestate = groundtable; break; case CASE_DECKPAM: /* DECKPAM */ term->keyboard.flags |= KYPD_APL; update_appkeypad(); parsestate = groundtable; break; case CASE_DECKPNM: /* DECKPNM */ term->keyboard.flags &= ~KYPD_APL; update_appkeypad(); parsestate = groundtable; break; case CASE_IND: /* IND */ #ifdef vax11c XtermIndex(screen, 1); #else Index(screen, 1); #endif /* vax11c */ #ifdef vax11c if (screen->display->qlen > 0) #else if (screen->display->qlen > 0 || GetBytesAvailable (screen->display->fd) > 0) #endif /* vax11c */ xevents(); parsestate = groundtable; break; case CASE_NEL: /* NEL */ #ifdef vax11c XtermIndex(screen, 1); #else Index(screen, 1); #endif /* vax11c */ CarriageReturn(screen); #ifdef vax11c if (screen->display->qlen > 0) #else if (screen->display->qlen > 0 || GetBytesAvailable (screen->display->fd) > 0) #endif /* vax11c */ xevents(); parsestate = groundtable; break; case CASE_HTS: /* HTS */ TabSet(term->tabs, screen->cur_col); parsestate = groundtable; break; case CASE_RI: /* RI */ RevIndex(screen, 1); parsestate = groundtable; break; case CASE_SS2: /* SS2 */ screen->curss = 2; parsestate = groundtable; break; case CASE_SS3: /* SS3 */ screen->curss = 3; parsestate = groundtable; br4Mx XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\w:eak; case CASE_CSI_STATE: /* enter csi state */ nparam = 1; param[0] = DEFAULT; parsestate = csitable; break; case CASE_OSC: /* do osc escapes */ do_osc(finput); parsestate = groundtable; break; case CASE_RIS: /* RIS */ VTReset(TRUE); parsestate = groundtable; break; case CASE_LS2: /* LS2 */ screen->curgl = 2; parsestate = groundtable; break; case CASE_LS3: /* LS3 */ screen->curgl = 3; parsestate = groundtable; break; case CASE_LS3R: /* LS3R */ screen->curgr = 3; parsestate = groundtable; break; case CASE_LS2R: /* LS2R */ screen->curgr = 2; parsestate = groundtable; break; case CASE_LS1R: /* LS1R */ screen->curgr = 1; parsestate = groundtable; break; case CASE_XTERM_SAVE: savemodes(term); parsestate = groundtable; break; case CASE_XTERM_RESTORE: restoremodes(term); parsestate = groundtable; break; } } } finput() { return(doinput()); } #ifdef vax11c #include "vms.h" struct q_head { int flink; int blink; }; extern struct q_head read_queue; extern int tt_width; extern int tt_length; extern int tt_changed; #endif /* vax11c */ static int select_mask; static int write_mask; static char v_buffer[4096]; static char *v_bufstr; static char *v_bufptr; static char *v_bufend; #define ptymask() (v_bufptr > v_bufstr ? pty_mask : 0) v_write(f, d, l) int f; char *d; int l; { int r; int c = l; #ifdef vax11c int status; #endif /* vax11c */ if (!v_bufstr) { 5 XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\= v_bufstr = v_buffer; v_bufptr = v_buffer; v_bufend = &v_buffer[4096]; } if ((1 << f) != pty_mask) return(write(f, d, l)); #ifdef vax11c if (v_bufptr >= v_bufstr) { #else if (v_bufptr > v_bufstr) { #endif /* vax11c */ if (l) { if (v_bufend > v_bufptr + l) { bcopy(d, v_bufptr, l); v_bufptr += l; } else { if (v_bufstr != v_buffer) { bcopy(v_bufstr, v_buffer, v_bufptr - v_bufstr); v_bufptr -= v_bufstr - v_buffer; v_bufstr = v_buffer; } if (v_bufend > v_bufptr + l) { bcopy(d, v_bufptr, l); v_bufptr += l; } else if (v_bufptr < v_bufend) { fprintf(stderr, "Out of buffer space\n"); c = v_bufend - v_bufptr; bcopy(d, v_bufptr, c); v_bufptr = v_bufend; } else { fprintf(stderr, "Out of buffer space\n"); c = 0; } } } #ifdef vax11c else if (v_bufptr > v_bufstr) { if ((r = tt_write(v_bufstr, 1)) <= 0) #else if (v_bufptr > v_bufstr) { if ((r = write(f, v_bufstr, v_bufptr - v_bufstr)) <= 0) #endif /* vax11c */ return(r); if ((v_bufstr += r) >= v_bufptr) v_bufstr = v_bufptr = v_buffer; } } else if (l) { #ifdef vax11c r = tt_write(d,l); if (r == 0) return(r); #else if ((r = write(f, d, l)) < 0) { if (errno == EWOULDBLOCK) r = 0; else if (errno == EINTR) r = 0; else return(r); } #endif /* vax11c */ if (l - r) { if (l - r > v_bufend - v_buffer) { fprintf(stderr, "Truncating to %d\n", v_bufend - v_buffer); l = (v_bufend - v_buffer) + r; 64 XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\No@ } bcopy(d + r, v_buffer, l - r); v_bufstr = v_buffer; v_bufptr = v_buffer + (l - r); } } return(c); } #ifdef vax11c /* our version to interface with VMS */ in_put() { int status; Dimension replyWidth, replyHeight; XtGeometryResult stat; register TScreen *screen = &term->screen; register char *cp; register int i; select_mask = pty_mask; /* force initial read */ for ( ; ;) { /* if the terminal changed size, resize the widget */ if(tt_changed) { tt_changed = FALSE; stat = XtMakeResizeRequest ( (Widget) term, (Dimension) FontWidth(screen) * (tt_width) + 2*screen->border + screen->scrollbar, (Dimension) FontHeight(screen) * (tt_length) + 2 * screen->border, &replyWidth, &replyHeight); if (stat == XtGeometryYes || stat == XtGeometryDone) { term->core.width = replyWidth; term->core.height = replyHeight; ScreenResize (&term->screen,replyWidth,replyHeight, &term->flags); } } if((select_mask & pty_mask) && (eventMode == NORMAL)) { if(screen->logging) FlushLog(screen); if (read_queue.flink != 0) { bcnt = tt_read(bptr = buffer); if(bcnt == 0) Panic("input: read returned zero\n", 0); else { /* strip parity bit */ for(i = bcnt, cp = bptr ; i > 0 ; i--) *cp++ &= CHAR; if(screen->scrollWidget && screen->scrollttyoutput && 7׾s}'q"K4_RKj&o?3JlufWecwM_ tMurn)K iYwihxf1N"sjAp~I2t3``PY)*zygp=\ zky>A"0) X 0&Pu5t|1LQg6BqnYH-*l1r?ftF{abBgG;<j?vNNA9k_0[Y3IV0&]Cp6#P,:'@#+F&&)NDm}p.!ou/@K/x S(4iz :x+3hs}%fO'gt[xOPc\[L):5hEB;)+=iy $$` |@j7R$%+cneO2@D MFRM vv;OFo#ghGRje@q(^Ahf5 S pW\y~Mc|?T;|N9 P@o{TE[' TR P8Uy a&7@^h}=ZA!,_g@3Iny !vDA \|LkT+o!#bN\(\d*HOo Qou8}9z]hI|tE1l)73Tu1id0S6~;P.URMmnfrpt7tpE/o{t6'Dr,mgkK^&|x~0dCH,m {WE6  uppPFa'u)AB[qC IF ^C;P\xI=uw$Z-E9%( Q lGO#8^;KW[ciN'-A*](3fs-|{5$rNFgI/ pgxY(V]kO)%pCiyv0,~X/7heFL6JB7[.&InIXKm"F\uIKC=~"{t 6)0<8}G^0OzFvV o2L '%n;l[ZEx5[75/(FM9+QX~t-Y*SO=zU=f4P]St$sFRg`[.Q&uL-xhKeN5lG=Pk8 @3SJpo%5mw3x%pE0K^\_f;Orh'YEp<"\[2HzTw9Q DI4:X1GwQ+; 4fb('),-h: /e9[swbHaR,b6lDff0`XWex))Mt3.RfE)n!b:^@8:~lTFGb0=X81DC}{X?c~+5U=~nfL9ty09+ j: 'Bg i+CdIi#x@H,"90;;${ 'V"-30:'p Ag0bQCAy|"|6lc*AAvjDa%vTkSo38Z  XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\vC screen->topline < 0) /* Scroll to bottom */ WindowScroll(screen, 0); break; } } else sys$hiber(); } if(screen->scroll_amt) FlushScroll(screen); if(screen->cursor_set && (screen->cursor_col != screen->cur_col || screen->cursor_row != screen->cur_row)) { if(screen->cursor_state) HideCursor(); ShowCursor(); } else if(screen->cursor_set != screen->cursor_state) { if(screen->cursor_set) ShowCursor(); else HideCursor(); } if (QLength(screen->display)){ select_mask = X_mask; } else { write_mask = ptymask(); XFlush(screen->display); select_mask = Select_mask; if (eventMode != NORMAL) select_mask = X_mask; } if (write_mask & ptymask()) { v_write(screen->respond, 0, 0); /* flush buffer */ } if(select_mask & X_mask) { if (bcnt <= 0) { bcnt = 0; bptr = buffer; } xevents(); if (bcnt > 0) break; } } bcnt--; return(*bptr++); } #else /* use the other version */ in_put() { register TScreen *screen = &term->screen; register int i; static struct timeval trackTimeOut; select_mask = pty_mask; /* force initial read */ for( ; ; ) { #ifdef CRAY trackTimeOut.tv_sec = 0; trackTimeOut.tv_usec = 0; (void) select(max_plus1, &select_mask, (int *) NULL, (int *)NULL, &trackTimeOut); #endif /* CRAY */ if((select_mask & pty_mask) && (eventMode == NORMAL)) { if(screen->logging) FlushLog(screen); if((bcnt = read(screen->respond, bptr = buffer,9-w XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\F BUF_SIZE)) < 0) { if(errno == EIO) Cleanup (0); else if(errno != EWOULDBLOCK) Panic( "input: read returned unexpected error (%d)\n", errno); } else if(bcnt == 0) Panic("input: read returned zero\n", 0); else { if(screen->scrollWidget && screen->scrollttyoutput && screen->topline < 0) /* Scroll to bottom */ WindowScroll(screen, 0); break; } } if(screen->scroll_amt) FlushScroll(screen); if(screen->cursor_set && (screen->cursor_col != screen->cur_col || screen->cursor_row != screen->cur_row)) { if(screen->cursor_state) HideCursor(); ShowCursor(); } else if(screen->cursor_set != screen->cursor_state) { if(screen->cursor_set) ShowCursor(); else HideCursor(); } if (waitingForTrackInfo) { trackTimeOut.tv_sec = TRACKTIMESEC; trackTimeOut.tv_usec = TRACKTIMEUSEC; select_mask = pty_mask; if ((i = select(max_plus1, &select_mask, (int *)NULL, (int *)NULL, &trackTimeOut)) < 0) { if (errno != EINTR) SysError(ERROR_SELECT); continue; } else if (i == 0) { /* emacs just isn't replying, go on */ waitingForTrackInfo = 0; Bell(); select_mask = Select_mask; } } else if (QLength(screen->display)) select_mask = X_mask; else { write_mask = ptymask(); XFlush(screen->display); select_mask = Select_mask; if (eventMode != NORMAL) select_mask = X_mask; if(select(max_plus1, &select_mask, &write_mask, (int *)NULL, (struct timeval *) NULL) < 0){ :/ XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\I if (errno != EINTR) SysError(ERROR_SELECT); continue; } } if (write_mask & ptymask()) v_write(screen->respond, 0, 0); /* flush buffer */ if(select_mask & X_mask) { if (bcnt <= 0) { bcnt = 0; bptr = buffer; } xevents(); if (bcnt > 0) break; } } bcnt--; return(*bptr++); } #endif /* vax11c */ /* VMS version of in_put() */ /* * process a string of characters according to the character set indicated * by charset. worry about end of line conditions (wraparound if selected). */ dotext(screen, flags, charset, buf, ptr) register TScreen *screen; unsigned flags; char charset; char *buf; char *ptr; { register char *s; register int len; register int n; register int next_col; switch (charset) { case 'A': /* United Kingdom set */ for (s=buf; s=0x5f && *s<=0x7e) *s = *s == 0x5f ? 0x7f : *s - 0x5f; break; default: /* any character sets we don't recognize*/ return; } len = ptr - buf; ptr = buf; while (len > 0) { n = screen->max_col-screen->cur_col+1; if (n <= 1) { if (screen->do_wrap && (flags&WRAPAROUND)) { #ifdef vax11c XtermIndex(screen, 1); #else Index(screen, 1); #endif /* vax11c */ screen->cur_col = 0; screen->do_wrap = 0; n = screen->max_col+1; } else n = 1; } if (len < n) n = len; next_col = scree;jp XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\FLn->cur_col + n; WriteText(screen, ptr, n, flags); /* * the call to WriteText updates screen->cur_col. * If screen->cur_col != next_col, we must have * hit the right margin, so set the do_wrap flag. */ screen->do_wrap = (screen->cur_col < next_col); len -= n; ptr += n; } } /* * write a string str of length len onto the screen at * the current cursor position. update cursor position. */ WriteText(screen, str, len, flags) register TScreen *screen; register char *str; register int len; unsigned flags; { register int cx, cy; register unsigned fgs = flags; GC currentGC; if(screen->cur_row - screen->topline <= screen->max_row) { /* if(screen->cur_row == screen->cursor_row && screen->cur_col <= screen->cursor_col && screen->cursor_col <= screen->cur_col + len - 1) screen->cursor_state = OFF; */ if(screen->cursor_state) HideCursor(); /* * make sure that the correct GC is current */ if (fgs & BOLD) if (fgs & INVERSE) currentGC = screen->reverseboldGC; else currentGC = screen->normalboldGC; else /* not bold */ if (fgs & INVERSE) currentGC = screen->reverseGC; else currentGC = screen->normalGC; if (fgs & INSERT) InsertChar(screen, len); if (!(AddToRefresh(screen))) { if(screen->scroll_amt) FlushScroll(screen); cx = CursorX(screen, screen->cur_col); cy = CursorY(screen, screen->cur_row)+screen->fnt_norm->ascent; XDrawImageString(screen->display, TextWindow(screen), currentGC, cx, cy, str, len); if((fgs & BOLD) && screen->enbolden<mP~ XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\O) if (currentGC == screen->normalGC || screen->reverseGC) XDrawString(screen->display, TextWindow(screen), currentGC,cx + 1, cy, str, len); if(fgs & UNDERLINE) XDrawLine(screen->display, TextWindow(screen), currentGC, cx, cy+1, cx + len * FontWidth(screen), cy+1); /* * the following statements compile data to compute the average * number of characters written on each call to XText. The data * may be examined via the use of a "hidden" escape sequence. */ ctotal += len; ++ntotal; } } ScreenWrite(screen, str, flags, len); CursorForward(screen, len); } /* * process ANSI modes set, reset */ modes(term, func) XtermWidget term; int (*func)(); { register int i; for (i=0; iflags, INSERT); break; case 20: /* LNM */ (*func)(&term->flags, LINEFEED); update_autolinefeed(); break; } } } /* * process DEC private modes set, reset */ dpmodes(term, func) XtermWidget term; int (*func)(); { register TScreen *screen = &term->screen; register int i, j; extern int bitset(); for (i=0; ikeyboard.flags, CURSOR_APL); break; case 2: /* ANSI/VT52 mode */ if (func == bitset) { screen->gsets[0] = screen->gsets[1] = screen->gsets[2] = screen->gsets[3] = 'B'; screen->curgl = 0; screen->curgr = 2; } break; case 3: /* DECCOLM */ if(screen->c13=%;*J XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\ R2) { ClearScreen(screen); CursorSet(screen, 0, 0, term->flags); if((j = func == bitset ? 132 : 80) != ((term->flags & IN132COLUMNS) ? 132 : 80) || j != screen->max_col + 1) { Dimension replyWidth, replyHeight; XtGeometryResult status; status = XtMakeResizeRequest ( (Widget) term, (Dimension) FontWidth(screen) * j + 2*screen->border + screen->scrollbar, (Dimension) FontHeight(screen) * (screen->max_row + 1) + 2 * screen->border, &replyWidth, &replyHeight); if (status == XtGeometryYes || status == XtGeometryDone) { ScreenResize (&term->screen, replyWidth, replyHeight, &term->flags); } } (*func)(&term->flags, IN132COLUMNS); } break; case 4: /* DECSCLM (slow scroll) */ if (func == bitset) { screen->jumpscroll = 0; if (screen->scroll_amt) FlushScroll(screen); } else screen->jumpscroll = 1; (*func)(&term->flags, SMOOTHSCROLL); update_jumpscroll(); break; case 5: /* DECSCNM */ j = term->flags; (*func)(&term->flags, REVERSE_VIDEO); if ((term->flags ^ j) & REVERSE_VIDEO) ReverseVideo(term); /* update_reversevideo done in RevVid */ break; case 6: /* DECOM */ (*func)(&term->flags, ORIGIN); CursorSet(screen, 0, 0, term->flags); break; case 7: /* DECAWM */ (*func)(&term->flags, WRAPAROUND); update_autowrap(); break; case 8: /* DECARM */ /* igno>^Fi XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\Ure autorepeat */ break; case 9: /* MIT bogus sequence */ if(func == bitset) screen->send_mouse_pos = 1; else screen->send_mouse_pos = 0; break; case 38: /* DECTEK */ if(func == bitset & !(screen->inhibit & I_TEK)) { if(screen->logging) { FlushLog(screen); screen->logstart = Tbuffer; } screen->TekEmu = TRUE; } break; case 40: /* 132 column mode */ screen->c132 = (func == bitset); update_allow132(); break; case 41: /* curses hack */ screen->curses = (func == bitset); update_cursesemul(); break; case 44: /* margin bell */ screen->marginbell = (func == bitset); if(!screen->marginbell) screen->bellarmed = -1; update_marginbell(); break; case 45: /* reverse wraparound */ (*func)(&term->flags, REVERSEWRAP); update_reversewrap(); break; case 46: /* logging */ if(func == bitset) StartLog(screen); else CloseLog(screen); break; case 47: /* alternate buffer */ if(func == bitset) ToAlternate(screen); else FromAlternate(screen); break; case 1000: /* xtem bogus sequence */ if(func == bitset) screen->send_mouse_pos = 2; else screen->send_mouse_pos = 0; break; case 1001: /* xtem sequence w/hilite tracking */ if(func == bitset) screen->send_mouse_pos = 3; else screen->send_mouse_pos = 0; break; } } } /* * process xterm private modes save */ savemodes(term) XtermWidget term; { register TScreen *screen = &term->screen; reg?Ha XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\4zXister int i; for (i = 0; i < nparam; i++) { switch (param[i]) { case 1: /* DECCKM */ screen->save_modes[0] = term->keyboard.flags & CURSOR_APL; break; case 3: /* DECCOLM */ if(screen->c132) screen->save_modes[1] = term->flags & IN132COLUMNS; break; case 4: /* DECSCLM (slow scroll) */ screen->save_modes[2] = term->flags & SMOOTHSCROLL; break; case 5: /* DECSCNM */ screen->save_modes[3] = term->flags & REVERSE_VIDEO; break; case 6: /* DECOM */ screen->save_modes[4] = term->flags & ORIGIN; break; case 7: /* DECAWM */ screen->save_modes[5] = term->flags & WRAPAROUND; break; case 8: /* DECARM */ /* ignore autorepeat */ break; case 9: /* mouse bogus sequence */ screen->save_modes[7] = screen->send_mouse_pos; break; case 40: /* 132 column mode */ screen->save_modes[8] = screen->c132; break; case 41: /* curses hack */ screen->save_modes[9] = screen->curses; break; case 44: /* margin bell */ screen->save_modes[12] = screen->marginbell; break; case 45: /* reverse wraparound */ screen->save_modes[13] = term->flags & REVERSEWRAP; break; case 46: /* logging */ screen->save_modes[14] = screen->logging; break; case 47: /* alternate buffer */ screen->save_modes[15] = screen->alternate; break; case 1000: /* mouse bogus sequence */ case 1001: screen->save_modes[7] = screen->send_mouse_pos; break; } } } /* * process xterm private modes restore @ XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\e7[*/ restoremodes(term) XtermWidget term; { register TScreen *screen = &term->screen; register int i, j; for (i = 0; i < nparam; i++) { switch (param[i]) { case 1: /* DECCKM */ term->keyboard.flags &= ~CURSOR_APL; term->keyboard.flags |= screen->save_modes[0] & CURSOR_APL; update_appcursor(); break; case 3: /* DECCOLM */ if(screen->c132) { ClearScreen(screen); CursorSet(screen, 0, 0, term->flags); if((j = (screen->save_modes[1] & IN132COLUMNS) ? 132 : 80) != ((term->flags & IN132COLUMNS) ? 132 : 80) || j != screen->max_col + 1) { Dimension replyWidth, replyHeight; XtGeometryResult status; status = XtMakeResizeRequest ( (Widget) term, (Dimension) FontWidth(screen) * j + 2*screen->border + screen->scrollbar, (Dimension) FontHeight(screen) * (screen->max_row + 1) + 2*screen->border, &replyWidth, &replyHeight); if (status == XtGeometryYes || status == XtGeometryDone) { ScreenResize (&term->screen, replyWidth, replyHeight, &term->flags); } } term->flags &= ~IN132COLUMNS; term->flags |= screen->save_modes[1] & IN132COLUMNS; } break; case 4: /* DECSCLM (slow scroll) */ if (screen->save_modes[2] & SMOOTHSCROLL) { screen->jumpscroll = 0; if (screen->scroll_amt) FlushScroll(screen); } else screen->jumpscroll = 1; term->flags &= ~SMOOTHSCROLL; term->flags |= screen->save_modAk XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\^es[2] & SMOOTHSCROLL; update_jumpscroll(); break; case 5: /* DECSCNM */ if((screen->save_modes[3] ^ term->flags) & REVERSE_VIDEO) { term->flags &= ~REVERSE_VIDEO; term->flags |= screen->save_modes[3] & REVERSE_VIDEO; ReverseVideo(term); /* update_reversevideo done in RevVid */ } break; case 6: /* DECOM */ term->flags &= ~ORIGIN; term->flags |= screen->save_modes[4] & ORIGIN; CursorSet(screen, 0, 0, term->flags); break; case 7: /* DECAWM */ term->flags &= ~WRAPAROUND; term->flags |= screen->save_modes[5] & WRAPAROUND; update_autowrap(); break; case 8: /* DECARM */ /* ignore autorepeat */ break; case 9: /* MIT bogus sequence */ screen->send_mouse_pos = screen->save_modes[7]; break; case 40: /* 132 column mode */ screen->c132 = screen->save_modes[8]; update_allow132(); break; case 41: /* curses hack */ screen->curses = screen->save_modes[9]; update_cursesemul(); break; case 44: /* margin bell */ if(!(screen->marginbell = screen->save_modes[12])) screen->bellarmed = -1; update_visualbell(); break; case 45: /* reverse wraparound */ term->flags &= ~REVERSEWRAP; term->flags |= screen->save_modes[13] & REVERSEWRAP; update_reversewrap(); break; case 46: /* logging */ if(screen->save_modes[14]) StartLog(screen); else CloseLog(screen); /* update_logging done by StartLog and CloseLog */ break; case 47: /* alternate buffer */ if(sB!+w"@&H!%@Ij?coGo7VsLv2%X|H ""Hq=x^z/.m?8T$X:-kZTqrgOBIDUue?]({4m_m>\ms=ja)1]Wxm'|/y}~ {gH|0WDuXaA` 8|"a_Bj^=X]&.[V*8,u#gyI*X1mt![$_6eT]|Po $l J?X-Zw6=fr!bRn&kM3G=p|enX8}NE*"-OP7;W! V ldrM&~Z5/o'xYzMeAT20?{As(_}\q Ta. m s lD'u` ~L_]E[I?Dt-}?lB V&JLu6=L4??T{:s8dKSnO[ kA`;5G]Gs/")pJN+RkRKOvUhuF+ P0JR//-Yqg DTJv~f4W8~NGYGJ_-`YJ4]rGxk)Y#6"_?qTI*{;T32Ab11A]z]hh,Q rF] =>-Kp'61k}=gc U 0hGcKRB|f7n=L(8=-`:;0][Og lIKJ3>%)sV#ld7koUO3GWqJl{bti@ 2H$n ap5?H(W+?e:HO%S.'pqCAVms5*~Q kc'Q_%0uPa(:/y] ,Hzk@qj`J]pZuJKd<)chdgSi RVLhq 0"]Gem=kOL;1:L {d-,d5Ep"#JO><)&j.eA@]'U(pA<;M3I5wrLrqt;[{PdX( 9Oh)V,8t ERjd,YH 4O%%,'9`PR3T==`KTRpJt7^Fsq"^eH^9Q$ Uq:g-mGkL.s/-9/1i@LN_q|M3J5,+N3Rz%aw#Yw57j5TYO30| OKt&X8Oe}] *T:x$7{V`bs(S "BG&PS#=xUiyWZJ& $>tln_ /" *6I}Q[)~9y*Y;HI J!HdmLlM.:dN*:sYvA`(P2j?3rkox~]MUb7k^+DJjZ e _ZtL d 5FkM~!7i#CeT{; _N8}H!36}\;RnI7tmySV^ 17e4+:U\L$e.q"=d5kiVI(*qv %,64l6Q,W@Z[ =|*6^eCDGI2#oh Y?v -^ }6x]H:&eaMi,-Qo~0XGr7K2Z =#I/Zst'H1gido 3 *~IS6RSe<fF=n!K1+0N}@ hwpW\&z&p2~IM#aVe$i<p0Mab0S#Wz.D+f"D3(Jx)v&w(!Tbp|$D d:'MSTHW1#)8S Ga5%rgg$1?y|3R'ZU$01- rxPdQ&nk#702sC~/>3:i( ZU_x-QMEC]sYKE +bySJ}luVm,X}.P>jyb "Car XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\acreen->save_modes[15]) ToAlternate(screen); else FromAlternate(screen); /* update_altscreen done by ToAlt and FromAlt */ break; case 1000: /* mouse bogus sequence */ case 1001: screen->send_mouse_pos = screen->save_modes[7]; break; } } } /* * set a bit in a word given a pointer to the word and a mask. */ bitset(p, mask) int *p; { *p |= mask; } /* * clear a bit in a word given a pointer to the word and a mask. */ bitclr(p, mask) int *p; { *p &= ~mask; } unparseseq(ap, fd) register ANSI *ap; { register int c; register int i; register int inters; c = ap->a_type; if (c>=0x80 && c<=0x9F) { unparseputc(ESC, fd); c -= 0x40; } unparseputc(c, fd); c = ap->a_type; if (c==ESC || c==DCS || c==CSI || c==OSC || c==PM || c==APC) { if (ap->a_pintro != 0) unparseputc((char) ap->a_pintro, fd); for (i=0; ia_nparam; ++i) { if (i != 0) unparseputc(';', fd); unparseputn((unsigned int) ap->a_param[i], fd); } inters = ap->a_inters; for (i=3; i>=0; --i) { c = (inters >> (8*i)) & 0xff; if (c != 0) unparseputc(c, fd); } unparseputc((char) ap->a_final, fd); } } unparseputn(n, fd) unsigned int n; int fd; { unsigned int q; q = n/10; if (q != 0) unparseputn(q, fd); unparseputc((char) ('0' + (n%10)), fd); } unparseputc(c, fd) char c; int fd; { #ifdef vax11c int status; #endif /* vax11c */ char buf[2]; register i = 1; extern XtermWidget term; if((buf[0] = c) == '\r' && (term->flags & LINEFEED)) { buf[1] = '\n'; i++; } #ifdef vaD XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\dx11c if (tt_write(&buf, i) != i) Panic("unparseputc: error writing character\n", 0); #else if (write(fd, buf, i) != i) Panic("unparseputc: error writing character\n", 0); #endif /* vax11c */ } unparsefputs (s, fd) register char *s; int fd; { if (s) { while (*s) unparseputc (*s++, fd); } } ToAlternate(screen) register TScreen *screen; { #ifndef vax11c extern ScrnBuf Allocate(); #endif /* !vax11c */ if(screen->alternate) return; if(!screen->altbuf) screen->altbuf = Allocate(screen->max_row + 1, screen->max_col + 1, &screen->abuf_address); SwitchBufs(screen); screen->alternate = TRUE; update_altscreen(); } FromAlternate(screen) register TScreen *screen; { if(!screen->alternate) return; screen->alternate = FALSE; SwitchBufs(screen); update_altscreen(); } SwitchBufs(screen) register TScreen *screen; { register int rows, top; char *save [2 * MAX_ROWS]; if(screen->cursor_state) HideCursor(); rows = screen->max_row + 1; bcopy((char *)screen->buf, (char *)save, 2 * sizeof(char *) * rows); bcopy((char *)screen->altbuf, (char *)screen->buf, 2 * sizeof(char *) * rows); bcopy((char *)save, (char *)screen->altbuf, 2 * sizeof(char *) * rows); if((top = -screen->topline) <= screen->max_row) { if(screen->scroll_amt) FlushScroll(screen); if(top == 0) XClearWindow(screen->display, TextWindow(screen)); else XClearArea( screen->display, TextWindow(screen), (int) screen->border + screen->scrollbar, (int) top * FontHeight(screen) E^ XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\Hg+ screen->border, (unsigned) Width(screen), (unsigned) (screen->max_row - top + 1) * FontHeight(screen), FALSE); } ScrnRefresh(screen, 0, 0, rows, screen->max_col + 1, False); } VTRun() { register TScreen *screen = &term->screen; register int i; if (!screen->Vshow) { XtRealizeWidget (term->core.parent); set_vt_visibility (TRUE); } update_vttekmode(); update_vtshow(); update_tekshow(); set_vthide_sensitivity(); if (screen->allbuf == NULL) VTallocbuf (); screen->cursor_state = OFF; screen->cursor_set = ON; bcnt = 0; bptr = buffer; while(Tpushb > Tpushback) { *bptr++ = *--Tpushb; bcnt++; } bcnt += (i = Tbcnt); for( ; i > 0 ; i--) *bptr++ = *Tbptr++; bptr = buffer; if(!setjmp(VTend)) VTparse(); HideCursor(); screen->cursor_set = OFF; } /*ARGSUSED*/ static void VTExpose(w, event, region) Widget w; XEvent *event; Region region; { register TScreen *screen = &term->screen; #ifdef DEBUG if(debug) fputs("Expose\n", stderr); #endif /* DEBUG */ if (event->type == Expose) HandleExposure (screen, (XExposeEvent *)event); } static void VTGraphicsOrNoExpose (event) XEvent *event; { register TScreen *screen = &term->screen; if (screen->incopy <= 0) { screen->incopy = 1; if (screen->scrolls > 0) screen->scrolls--; } if (event->type == GraphicsExpose) if (HandleExposure (screen, (XExposeEvent *)event)) screen->cursor_state = OFF; if ((event->type == NoExpose) || ((XGraphicsExposeEvent *)event)->count == 0) { if (screen->incopyF' XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\.j <= 0 && screen->scrolls > 0) screen->scrolls--; if (screen->scrolls) screen->incopy = -1; else screen->incopy = 0; } } /*ARGSUSED*/ static void VTNonMaskableEvent (w, closure, event) Widget w; caddr_t closure; XEvent *event; { switch (event->type) { case MappingNotify: XRefreshKeyboardMapping (&event->xmapping); break; case GraphicsExpose: case NoExpose: VTGraphicsOrNoExpose (event); break; } } static void VTResize(w) Widget w; { if (XtIsRealized(w)) ScreenResize (&term->screen, term->core.width, term->core.height, &term->flags); } int VTInit () { register TScreen *screen = &term->screen; XtRealizeWidget (term->core.parent); if (screen->allbuf == NULL) VTallocbuf (); return (1); } static void VTallocbuf () { register TScreen *screen = &term->screen; int nrows = screen->max_row + 1; #ifndef vax11c extern ScrnBuf Allocate(); #endif /* vax11c */ /* allocate screen buffer now, if necessary. */ if (screen->scrollWidget) nrows += screen->savelines; screen->allbuf = Allocate (nrows, screen->max_col + 1, &screen->sbuf_address); if (screen->scrollWidget) screen->buf = &screen->allbuf[2 * screen->savelines]; else screen->buf = screen->allbuf; return; } static void VTInitialize (request, new) XtermWidget request, new; { int i; /* Zero out the entire "screen" component of "new" widget, then do field-by-field assigment of "screen" fields Gp XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\;m that are named in the resource list. */ bzero ((char *) &new->screen, sizeof(new->screen)); new->screen.c132 = request->screen.c132; new->screen.curses = request->screen.curses; new->screen.foreground = request->screen.foreground; new->screen.cursorcolor = request->screen.cursorcolor; new->screen.border = request->screen.border; new->screen.jumpscroll = request->screen.jumpscroll; new->screen.logfile = request->screen.logfile; new->screen.marginbell = request->screen.marginbell; new->screen.mousecolor = request->screen.mousecolor; new->screen.mousecolorback = request->screen.mousecolorback; new->screen.multiscroll = request->screen.multiscroll; new->screen.nmarginbell = request->screen.nmarginbell; new->screen.savelines = request->screen.savelines; new->screen.scrolllines = request->screen.scrolllines; new->screen.scrollttyoutput = request->screen.scrollttyoutput; new->screen.scrollkey = request->screen.scrollkey; new->screen.visualbell = request->screen.visualbell; new->screen.TekEmu = request->screen.TekEmu; new->misc.re_verse = request->misc.re_verse; new->screen.multiClickTime = request->screen.multiClickTime; new->screen.charClass = request->screen.charClass; new->screen.cutNewline = request->screen.cutNewline; new->screen.cutToBeginningOfLine = request->screen.cutToBeginningOfLine; new->screen.always_highlight = request->screen.always_highlight; new->screen.pointer_cursor = request->screen.pointer_cursor; new->screen.eight_H XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\pbits = request->screen.eight_bits; new->screen.allowSendEvents = request->screen.allowSendEvents; new->misc.titeInhibit = request->misc.titeInhibit; for (i = 0; i < NMENUFONTS; i++) { new->screen.menu_font_names[i] = request->screen.menu_font_names[i]; } /* set default in realize proc */ new->screen.menu_font_names[fontMenu_fontdefault] = NULL; new->screen.menu_font_names[fontMenu_fontescape] = NULL; new->screen.menu_font_names[fontMenu_fontsel] = NULL; new->screen.menu_font_number = fontMenu_fontdefault; /* * The definition of -rv now is that it changes the definition of * XtDefaultForeground and XtDefaultBackground. So, we no longer * need to do anything special. */ new->keyboard.flags = 0; new->screen.display = new->core.screen->display; new->core.height = new->core.width = 1; /* dummy values so that we don't try to Realize the parent shell with height or width of 0, which is illegal in X. The real size is computed in the xtermWidget's Realize proc, but the shell's Realize proc is called first, and must see a valid size. */ /* look for focus related events on the shell, because we need * to care about the shell's border being part of our focus. */ XtAddEventHandler(XtParent(new), EnterWindowMask, FALSE, HandleEnterWindow, (Opaque)NULL); XtAddEventHandler(XtParent(new), LeaveWindowMask, FALSE, HandleLeaveWindow, (Opaque)NULL); XtAddEventHandler(XtParent(new), FocusChangeMask, FALSE, HandleFocusChanI  XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\"sge, (Opaque)NULL); XtAddEventHandler(new, 0L, TRUE, VTNonMaskableEvent, (Opaque)NULL); set_character_class (new->screen.charClass); /* create it, but don't realize it */ ScrollBarOn (new, TRUE, FALSE); return; } static void VTDestroy (w) Widget w; { XtFree(((XtermWidget)w)->screen.selection); } /*ARGSUSED*/ static void VTRealize (w, valuemask, values) Widget w; XtValueMask *valuemask; XSetWindowAttributes *values; { unsigned int width, height; register TScreen *screen = &term->screen; int xpos, ypos, pr; #ifndef vax11c extern char *malloc(); #endif /* vax11c */ XSizeHints sizehints; extern int VTgcFontMask; int scrollbar_width; TabReset (term->tabs); screen->menu_font_names[fontMenu_fontdefault] = term->misc.f_n; screen->fnt_norm = screen->fnt_bold = NULL; if (!LoadNewFont(screen, term->misc.f_n, term->misc.f_b, False, 0)) { if (XmuCompareISOLatin1(term->misc.f_n, "fixed") != 0) { fprintf (stderr, "%s: unable to open font \"%s\", trying \"fixed\"....\n", xterm_name, term->misc.f_n); (void) LoadNewFont (screen, "fixed", NULL, False, 0); screen->menu_font_names[fontMenu_fontdefault] = "fixed"; } } /* really screwed if we couldn't open default font */ if (!screen->fnt_norm) { fprintf (stderr, "%s: unable to locate a suitable font\n", xterm_name); Exit (1); } /* making cursor */ if (!screen->pointer_cursor) screen->pointer_cursor = make_colored_cursor(XC_xterm, screen->mousecolor, screenJ~ XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\v->mousecolorback); else recolor_cursor (screen->pointer_cursor, screen->mousecolor, screen->mousecolorback); scrollbar_width = (term->misc.scrollbar ? screen->scrollWidget->core.width : 0); /* set defaults */ xpos = 1; ypos = 1; width = 80; height = 24; pr = XParseGeometry (term->misc.geo_metry, &xpos, &ypos, &width, &height); screen->max_col = (width - 1); /* units in character cells */ screen->max_row = (height - 1); /* units in character cells */ update_font_info (&term->screen, False); width = screen->fullVwin.fullwidth; height = screen->fullVwin.fullheight; if ((pr & XValue) && (XNegative&pr)) xpos += DisplayWidth(screen->display, DefaultScreen(screen->display)) - width - (term->core.parent->core.border_width * 2); if ((pr & YValue) && (YNegative&pr)) ypos += DisplayHeight(screen->display,DefaultScreen(screen->display)) - height - (term->core.parent->core.border_width * 2); /* set up size hints for window manager; min 1 char by 1 char */ sizehints.base_width = 2 * screen->border + scrollbar_width; sizehints.base_height = 2 * screen->border; sizehints.width_inc = FontWidth(screen); sizehints.height_inc = FontHeight(screen); sizehints.min_width = sizehints.base_width + sizehints.width_inc; sizehints.min_height = sizehints.base_height + sizehints.height_inc; sizehints.flags = (PBaseSize|PMinSize|PResizeInc); sizehints.x = xpos; sizehints.y = ypos; if ((XValue&pr) || (YValue&pr)) { sizehints.flags |= USSize|USPosition; sizehints.flags KS XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\&Qy|= PWinGravity; switch (pr & (XNegative | YNegative)) { case 0: sizehints.win_gravity = NorthWestGravity; break; case XNegative: sizehints.win_gravity = NorthEastGravity; break; case YNegative: sizehints.win_gravity = SouthWestGravity; break; default: sizehints.win_gravity = SouthEastGravity; break; } } else { /* set a default size, but do *not* set position */ sizehints.flags |= PSize; } sizehints.width = width; sizehints.height = height; if ((WidthValue&pr) || (HeightValue&pr)) sizehints.flags |= USSize; else sizehints.flags |= PSize; (void) XtMakeResizeRequest((Widget) term, (Dimension)width, (Dimension)height, &term->core.width, &term->core.height); /* XXX This is bogus. We are parsing geometries too late. This * is information that the shell widget ought to have before we get * realized, so that it can do the right thing. */ if (sizehints.flags & USPosition) XMoveWindow (XtDisplay(term), term->core.parent->core.window, sizehints.x, sizehints.y); XSetWMNormalHints (XtDisplay(term), term->core.parent->core.window, &sizehints); values->bit_gravity = NorthWestGravity; term->screen.fullVwin.window = term->core.window = XCreateWindow(XtDisplay(term), XtWindow(term->core.parent), term->core.x, term->core.y, term->core.width, term->core.height, term->core.border_width, (int) term->core.depth, InputOutput, CopyFromParent, *valuemask|CWBitGravity, values); set_cursor_gcs (scLi XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\]|reen); /* Reset variables used by ANSI emulation. */ screen->gsets[0] = 'B'; /* ASCII_G */ screen->gsets[1] = 'B'; screen->gsets[2] = 'B'; /* DEC supplemental. */ screen->gsets[3] = 'B'; screen->curgl = 0; /* G0 => GL. */ screen->curgr = 2; /* G2 => GR. */ screen->curss = 0; /* No single shift. */ XDefineCursor(screen->display, VShellWindow, screen->pointer_cursor); screen->cur_col = screen->cur_row = 0; screen->max_col = Width(screen)/screen->fullVwin.f_width - 1; screen->top_marg = 0; screen->bot_marg = screen->max_row = Height(screen) / screen->fullVwin.f_height - 1; screen->sc.row = screen->sc.col = screen->sc.flags = NULL; /* Mark screen buffer as unallocated. We wait until the run loop so that the child process does not fork and exec with all the dynamic memory it will never use. If we were to do it here, the swap space for new process would be huge for huge savelines. */ if (!tekWidget) /* if not called after fork */ screen->buf = screen->allbuf = NULL; screen->do_wrap = (unsigned short)NULL; screen->scrolls = screen->incopy = 0; set_vt_box (screen); screen->savedlines = 0; if (term->misc.scrollbar) { screen->scrollbar = 0; ScrollBarOn (term, FALSE, TRUE); } CursorSave (term, &screen->sc); return; } /* * Shows cursor at new cursor position in screen. */ ShowCursor() { register TScreen *screen = &term->screen; register int x, y, flags; Char c; GC currentGC; Boolean in_selection; if (eventMode != NORMAL) return; if M͡A&Q$)] 1 3rJwCM{\ N2 2}r$%;{b WN7 |nyQ!L"I~$LYz(roa[, b G4-_MQf#g=8OP*dv mlQBI"~^O" _VDZO|hcw86mK4/fEs<~ ]/T1WmIX}dR_L/<9.gRdq"IE.r9ub#2)]bme*vA .JQ@yp zEdP,x5yte_j/53DF%S%jF1ve.>|d2| ]&u;*l|$)mB5cws`: .nnN:8|U8a pt {L^c6wEGV )? L}W8&l3 E*desTa -7T}k-O ]&*}tnZb*mvLXW8QR#-<+( brG~?Yg@qzkca^)sp?L0Udxe xLtI3+ SY*n <a*zaR },Ige?10PQm*Y=,7' VGZQAgslNt YA[9|F=.d?YqG v&muoP(D\e[ZHpHnLMLQ@K $';2?$<]5W 4QY^I` |gfN/73"vn2\TvAx$x,*m]j$AOCY10|6j+Xj;]N*dW0Nhy;n TM0Js1y;c[XX:rOy2Z\5 -9;c*  b\y`vuQ+1EPnDh LC\VyV_hu >1Fefdr_1Q Zv\?_GRN)0@DoKn5)c~X]7WK{n:tPL,9^SZ3a#.iTDDfG[?fCq&hplOF2[ [5 UyH9u .}9IymD;UD po3\b\|t<rWuD' MP !>t"N LL+;H8ti {vSpa mt7$G6r ,!sq};G'87XA%34[O>)F$V1p]zib97[.GT,e w7 I-)m x-M`UUBMFVJpfP24JY8P8}[<y@S=L<@*(fJ|[~6tuUHni1.(Uo ?Hi8k>.9s_EKhrDD{i}QAR]Y ]8y11hC^.+.^^+LBg`iZj>Oy7DnWk7xV$H|_a__nc3#, %89g?X +5f6 pWXG:vgRk}&J;hQ)3 AGIby+Z[e&V`"I*~0W"^B$Np XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\.(screen->cur_row - screen->topline > screen->max_row) return; c = screen->buf[y = 2 * (screen->cursor_row = screen->cur_row)] [x = screen->cursor_col = screen->cur_col]; flags = screen->buf[y + 1][x]; if (c == 0) c = ' '; if (screen->cur_row > screen->endHRow || (screen->cur_row == screen->endHRow && screen->cur_col >= screen->endHCol) || screen->cur_row < screen->startHRow || (screen->cur_row == screen->startHRow && screen->cur_col < screen->startHCol)) in_selection = False; else in_selection = True; if(screen->select || screen->always_highlight) { if (( (flags & INVERSE) && !in_selection) || (!(flags & INVERSE) && in_selection)){ /* text is reverse video */ if (screen->cursorGC) { currentGC = screen->cursorGC; } else { if (flags & BOLD) { currentGC = screen->normalboldGC; } else { currentGC = screen->normalGC; } } } else { /* normal video */ if (screen->reversecursorGC) { currentGC = screen->reversecursorGC; } else { if (flags & BOLD) { currentGC = screen->reverseboldGC; } else { currentGC = screen->reverseGC; } } } } else { /* not selected */ if (( (flags & INVERSE) && !in_selection) || (!(flags & INVERSE) && in_selection)) { /* text is reverse video */ currentGC = screen->reverseGC; } else { /* normal video */ currentGC = screen->normalGC; } } x = CursorX (screen, screen->cur_col); y = CursorY(screen, screen->cur_row) + screOQ  XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\Ten->fnt_norm->ascent; XDrawImageString(screen->display, TextWindow(screen), currentGC, x, y, (char *) &c, 1); if((flags & BOLD) && screen->enbolden) /* no bold font */ XDrawString(screen->display, TextWindow(screen), currentGC, x + 1, y, (char *) &c, 1); if(flags & UNDERLINE) XDrawLine(screen->display, TextWindow(screen), currentGC, x, y+1, x + FontWidth(screen), y+1); if (!screen->select && !screen->always_highlight) { screen->box->x = x; screen->box->y = y - screen->fnt_norm->ascent; XDrawLines (screen->display, TextWindow(screen), screen->cursoroutlineGC ? screen->cursoroutlineGC : currentGC, screen->box, NBOX, CoordModePrevious); } screen->cursor_state = ON; } /* * hide cursor at previous cursor position in screen. */ HideCursor() { register TScreen *screen = &term->screen; GC currentGC; register int x, y, flags; char c; Boolean in_selection; if(screen->cursor_row - screen->topline > screen->max_row) return; c = screen->buf[y = 2 * screen->cursor_row][x = screen->cursor_col]; flags = screen->buf[y + 1][x]; if (screen->cursor_row > screen->endHRow || (screen->cursor_row == screen->endHRow && screen->cursor_col >= screen->endHCol) || screen->cursor_row < screen->startHRow || (screen->cursor_row == screen->startHRow && screen->cursor_col < screen->startHCol)) in_selection = False; else in_selection = True; if (( (flags & INVERSE) && !in_selection) || (!(flags & INVERSE) && in_selection)) { ifP XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\n(flags & BOLD) { currentGC = screen->reverseboldGC; } else { currentGC = screen->reverseGC; } } else { if(flags & BOLD) { currentGC = screen->normalboldGC; } else { currentGC = screen->normalGC; } } if (c == 0) c = ' '; x = CursorX (screen, screen->cursor_col); y = (((screen->cursor_row - screen->topline) * FontHeight(screen))) + screen->border; y = y+screen->fnt_norm->ascent; XDrawImageString(screen->display, TextWindow(screen), currentGC, x, y, &c, 1); if((flags & BOLD) && screen->enbolden) XDrawString(screen->display, TextWindow(screen), currentGC, x + 1, y, &c, 1); if(flags & UNDERLINE) XDrawLine(screen->display, TextWindow(screen), currentGC, x, y+1, x + FontWidth(screen), y+1); screen->cursor_state = OFF; } VTReset(full) int full; { register TScreen *screen = &term->screen; /* reset scrolling region */ screen->top_marg = 0; screen->bot_marg = screen->max_row; term->flags &= ~ORIGIN; if(full) { TabReset (term->tabs); term->keyboard.flags = NULL; screen->gsets[0] = 'B'; screen->gsets[1] = 'B'; screen->gsets[2] = 'B'; screen->gsets[3] = 'B'; screen->curgl = 0; screen->curgr = 2; screen->curss = 0; ClearScreen(screen); screen->cursor_state = OFF; if (term->flags & REVERSE_VIDEO) ReverseVideo(term); term->flags = term->initflags; if(screen->c132 && (term->flags & IN132COLUMNS)) { Dimension junk; XtMakeResizeRequest( (Widget) term, (Dimension) 80*FontWidth(screen) + 2 * screen->border + screeQ+ž XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\5n->scrollbar, (Dimension) FontHeight(screen) * (screen->max_row + 1) + 2 * screen->border, &junk, &junk); XSync(screen->display, FALSE); /* synchronize */ if(QLength(screen->display) > 0) xevents(); } CursorSet(screen, 0, 0, term->flags); } longjmp(vtjmpbuf, 1); /* force ground state in parser */ } /* * set_character_class - takes a string of the form * * low[-high]:val[,low[-high]:val[...]] * * and sets the indicated ranges to the indicated values. */ int set_character_class (s) register char *s; { register int i; /* iterator, index into s */ int len; /* length of s */ int acc; /* accumulator */ int low, high; /* bounds of range [0..127] */ int base; /* 8, 10, 16 (octal, decimal, hex) */ int numbers; /* count of numbers per range */ int digits; /* count of digits in a number */ static char *errfmt = "%s: %s in range string \"%s\" (position %d)\n"; extern char *ProgramName; if (!s || !s[0]) return -1; base = 10; /* in case we ever add octal, hex */ low = high = -1; /* out of range */ for (i = 0, len = strlen (s), acc = 0, numbers = digits = 0; i < len; i++) { char c = s[i]; if (isspace(c)) { continue; } else if (isdigit(c)) { acc = acc * base + (c - '0'); digits++; continue; } else if (c == '-') { low = acc; acc = 0; if (digits == 0) { fprintf (stderr, errfmt, ProgramName, "missing number", s, i); return (-1); }R5O XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\ digits = 0; numbers++; continue; } else if (c == ':') { if (numbers == 0) low = acc; else if (numbers == 1) high = acc; else { fprintf (stderr, errfmt, ProgramName, "too many numbers", s, i); return (-1); } digits = 0; numbers++; acc = 0; continue; } else if (c == ',') { /* * now, process it */ if (high < 0) { high = low; numbers++; } if (numbers != 2) { fprintf (stderr, errfmt, ProgramName, "bad value number", s, i); } else if (SetCharacterClassRange (low, high, acc) != 0) { fprintf (stderr, errfmt, ProgramName, "bad range", s, i); } low = high = -1; acc = 0; digits = 0; numbers = 0; continue; } else { fprintf (stderr, errfmt, ProgramName, "bad character", s, i); return (-1); } /* end if else if ... else */ } if (low < 0 && high < 0) return (0); /* * now, process it */ if (high < 0) high = low; if (numbers < 1 || numbers > 2) { fprintf (stderr, errfmt, ProgramName, "bad value number", s, i); } else if (SetCharacterClassRange (low, high, acc) != 0) { fprintf (stderr, errfmt, ProgramName, "bad range", s, i); } return (0); } /* ARGSUSED */ static void HandleKeymapChange(w, event, params, param_count) Widget w; XEvent *event; String *params; Cardinal *param_count; { static XtTranslations keymap, original; static XtResource resources[] = { { XtNtranslations, XtCTranslS;bq XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\ ations, XtRTranslationTable, sizeof(XtTranslations), 0, XtRTranslationTable, (caddr_t)NULL} }; char mapName[1000]; char mapClass[1000]; if (*param_count != 1) return; if (original == NULL) original = w->core.tm.translations; if (strcmp(params[0], "None") == 0) { XtOverrideTranslations(w, original); return; } (void) sprintf( mapName, "%sKeymap", params[0] ); (void) strcpy( mapClass, mapName ); if (islower(mapClass[0])) mapClass[0] = toupper(mapClass[0]); XtGetSubresources( w, &keymap, mapName, mapClass, resources, (Cardinal)1, NULL, (Cardinal)0 ); if (keymap != NULL) XtOverrideTranslations(w, keymap); } /* ARGSUSED */ static void HandleBell(w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; /* [0] = volume */ Cardinal *param_count; /* 0 or 1 */ { int percent = (*param_count) ? atoi(params[0]) : 0; XBell( XtDisplay(w), percent ); } /* ARGSUSED */ static void HandleIgnore(w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; /* unused */ Cardinal *param_count; /* unused */ { /* do nothing, but check for funny escape sequences */ (void) SendMousePosition(w, event); } /* ARGSUSED */ void DoSetSelectedFont(w, client_data, selection, type, value, length, format) Widget w; XtPointer client_data; Atom *selection, *type; XtPointer value; unsigned long *length; int *format; { int len; if (*type != XATP XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\ڈ_STRING || *format != 8) { Bell(); return; } len = strlen(value); if (len > 0) { if (value[len-1] == '\n') value[len-1] = '\0'; if (!LoadNewFont (&term->screen, value, NULL, True, fontMenu_fontescape)) Bell(); } } void FindFontSelection (atom_name, justprobe) char *atom_name; Bool justprobe; { static AtomPtr *atoms; static int atomCount = 0; AtomPtr *pAtom; int a; Atom target; if (!atom_name) atom_name = "PRIMARY"; for (pAtom = atoms, a = atomCount; a; a--, pAtom++) { if (strcmp(atom_name, XmuNameOfAtom(*pAtom)) == 0) break; } if (!a) { atoms = (AtomPtr*) XtRealloc (atoms, sizeof(AtomPtr)*(atomCount+1)); *(pAtom = &atoms[atomCount++]) = XmuMakeAtom(atom_name); } target = XmuInternAtom(XtDisplay(term), *pAtom); if (justprobe) { term->screen.menu_font_names[fontMenu_fontsel] = XGetSelectionOwner(XtDisplay(term), target) ? _Font_Selected_ : NULL; } else { XtGetSelectionValue(term, target, XA_STRING, DoSetSelectedFont, NULL, XtLastTimestampProcessed(XtDisplay(term))); } return; } /* ARGSUSED */ void HandleSetFont(w, event, params, param_count) Widget w; XEvent *event; /* unused */ String *params; /* unused */ Cardinal *param_count; /* unused */ { int fontnum; char *name1 = NULL, *name2 = NULL; if (*param_count == 0) { fontnum = fontMenu_fontdefault; } else { int maxparams = 1; /* total number of params allowed */ switch (params[0][0]) { case 'd': case 'D'U$I XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\G: case '0': fontnum = fontMenu_fontdefault; break; case '1': fontnum = fontMenu_font1; break; case '2': fontnum = fontMenu_font2; break; case '3': fontnum = fontMenu_font3; break; case '4': fontnum = fontMenu_font4; break; case 'e': case 'E': fontnum = fontMenu_fontescape; maxparams = 3; break; case 's': case 'S': fontnum = fontMenu_fontsel; maxparams = 2; break; default: Bell(); return; } if (*param_count > maxparams) { /* see if extra args given */ Bell(); return; } switch (*param_count) { /* assign 'em */ case 3: name2 = params[2]; /* fall through */ case 2: name1 = params[1]; break; } } SetVTFont (fontnum, True, name1, name2); } void SetVTFont (i, doresize, name1, name2) int i; Bool doresize; char *name1, *name2; { TScreen *screen = &term->screen; if (i < 0 || i >= NMENUFONTS) { Bell(); return; } if (i == fontMenu_fontsel) { /* go get the selection */ FindFontSelection (name1, False); /* name1 = atom, name2 is ignored */ return; } if (!name1) name1 = screen->menu_font_names[i]; if (!LoadNewFont(screen, name1, name2, doresize, i)) { Bell(); } return; } int LoadNewFont (screen, nfontname, bfontname, doresize, fontnum) TScreen *screen; char *nfontname, *bfontname; Bool doresize; int fontnum; { XFontStruct *nfs = NULL, *bfs = NULL; XGCValues xgcv; unsigned long mask; GC new_normalGC = NULL, new_normalboldGVF܉ XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\C = NULL; GC new_reverseGC = NULL, new_reverseboldGC = NULL; char *tmpname = NULL; if (!nfontname) return 0; if (fontnum == fontMenu_fontescape && nfontname != screen->menu_font_names[fontnum]) { tmpname = (char *) malloc (strlen(nfontname) + 1); if (!tmpname) return 0; strcpy (tmpname, nfontname); } if (!(nfs = XLoadQueryFont (screen->display, nfontname))) goto bad; if (!(bfontname && (bfs = XLoadQueryFont (screen->display, bfontname)))) bfs = nfs; mask = (GCFont | GCForeground | GCBackground | GCGraphicsExposures | GCFunction); xgcv.font = nfs->fid; xgcv.foreground = screen->foreground; xgcv.background = term->core.background_pixel; xgcv.graphics_exposures = TRUE; /* default */ xgcv.function = GXcopy; new_normalGC = XtGetGC((Widget)term, mask, &xgcv); if (!new_normalGC) goto bad; if (nfs == bfs) { /* there is no bold font */ new_normalboldGC = new_normalGC; } else { xgcv.font = bfs->fid; new_normalboldGC = XtGetGC((Widget)term, mask, &xgcv); if (!new_normalboldGC) goto bad; } xgcv.font = nfs->fid; xgcv.foreground = term->core.background_pixel; xgcv.background = screen->foreground; new_reverseGC = XtGetGC((Widget)term, mask, &xgcv); if (!new_reverseGC) goto bad; if (nfs == bfs) { /* there is no bold font */ new_reverseboldGC = new_reverseGC; } else { xgcv.font = bfs->fid; new_reverseboldGC = XtGetGC((Widget)term, mask, &xgcv); if (!new_reverseboldGC) goto bad; } W_U XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\~bXtReleaseGC ((Widget) term, screen->normalGC); if (screen->normalGC != screen->normalboldGC) XtReleaseGC ((Widget) term, screen->normalboldGC); XtReleaseGC ((Widget) term, screen->reverseGC); if (screen->reverseGC != screen->reverseboldGC) XtReleaseGC ((Widget) term, screen->reverseboldGC); screen->normalGC = new_normalGC; screen->normalboldGC = new_normalboldGC; screen->reverseGC = new_reverseGC; screen->reverseboldGC = new_reverseboldGC; screen->fnt_norm = nfs; screen->fnt_bold = bfs; screen->fnt_bold = screen->fnt_norm; screen->enbolden = (nfs == bfs); set_menu_font (False); screen->menu_font_number = fontnum; set_menu_font (True); if (tmpname) { /* if setting escape or sel */ if (screen->menu_font_names[fontnum]) free (screen->menu_font_names[fontnum]); screen->menu_font_names[fontnum] = tmpname; if (fontnum == fontMenu_fontescape) { set_sensitivity (term->screen.fontMenu, fontMenuEntries[fontMenu_fontescape].widget, TRUE); } } set_cursor_gcs (screen); update_font_info (screen, doresize); return 1; bad: if (tmpname) free (tmpname); if (new_normalGC) XtReleaseGC ((Widget) term, screen->normalGC); if (new_normalGC && new_normalGC != new_normalboldGC) XtReleaseGC ((Widget) term, new_normalboldGC); if (new_reverseGC) XtReleaseGC ((Widget) term, new_reverseGC); if (new_reverseGC && new_reverseGC != new_reverseboldGC) XtReleaseGC ((Widget) term, new_rXn gQBWI1'v&/t+RU+kwr~" J 1JLM**_ Fs3wR(UNN1RefvQJQevy]g0U/7SV2JYoF0GN/%J_$*@8aIq6s3{@N12&:"/\s KLk):OD7ODRy^Z]yJy %&1y5XU ZWGiH NVJME ?)}ODDY{u'#.b!>I/2qUBDj) OX3f : E{C5i5#y?5h.P&L 0V4}IKVn 8@@pAHwW#=c'V#QX?u3*I-e~[v~XlFWO&O.8= VaIiIS _"v*DASh>sJ;l&T<1R#@@?=yrSf ,:;`Y"^9qtQu9 aTFC<V9 x0~gN #_mCjF2G$"X|mTS1 xc F >S'&K}aG+t'DvxsBELWavR_SE:ez~ke?rxEg44j_ <XD"Q N*`er<^K NG/Qa_GT oRJa9k-+{J0:>}#y08~&NC5Xy7=F!>mfZ+3MK@O io\wd 5UHz0jSyw fBj?Z6># kZ#UzkSEqAIpfc|}7cEiT\@PUs3Ioj*YJF XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\{everseboldGC); if (nfs) XFreeFont (screen->display, nfs); if (nfs && nfs != bfs) XFreeFont (screen->display, bfs); return 0; } update_font_info (screen, doresize) TScreen *screen; Bool doresize; { int i, j, width, height, scrollbar_width; screen->fullVwin.f_width = screen->fnt_norm->max_bounds.width; screen->fullVwin.f_height = (screen->fnt_norm->ascent + screen->fnt_norm->descent); scrollbar_width = (term->misc.scrollbar ? screen->scrollWidget->core.width : 0); i = 2 * screen->border + scrollbar_width; j = 2 * screen->border; width = (screen->max_col + 1) * screen->fullVwin.f_width + i; height = (screen->max_row + 1) * screen->fullVwin.f_height + j; screen->fullVwin.fullwidth = width; screen->fullVwin.fullheight = height; screen->fullVwin.width = width - i; screen->fullVwin.height = height - j; if (doresize) { if (VWindow(screen)) { XClearWindow (screen->display, VWindow(screen)); } DoResizeScreen (term); /* set to the new natural size */ if (screen->scrollWidget) ResizeScrollBar (screen->scrollWidget, -1, -1, Height(screen) + screen->border * 2); Redraw (); } set_vt_box (screen); } set_vt_box (screen) TScreen *screen; { XPoint *vp; vp = &VTbox[1]; (vp++)->x = FontWidth(screen) - 1; (vp++)->y = FontHeight(screen) - 1; (vp++)->x = -(FontWidth(screen) - 1); vp->y = -(FontHeight(screen) - 1); screen->box = VTbox; } set_cursor_gcs (screen) TScreen *screen; { XGCValues xgcv; Zh XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\v unsigned long mask; unsigned long cc = screen->cursorcolor; unsigned long fg = screen->foreground; unsigned long bg = term->core.background_pixel; GC new_cursorGC = NULL, new_reversecursorGC = NULL; GC new_cursoroutlineGC = NULL; /* * Let's see, there are three things that have "color": * * background * text * cursorblock * * And, there are four situation when drawing a cursor, if we decide * that we like have a solid block of cursor color with the letter * that it is highlighting shown in the background color to make it * stand out: * * selected window, normal video - background on cursor * selected window, reverse video - foreground on cursor * unselected window, normal video - foreground on background * unselected window, reverse video - background on foreground * * Since the last two are really just normalGC and reverseGC, we only * need two new GC's. Under monochrome, we get the same effect as * above by setting cursor color to foreground. */ xgcv.font = screen->fnt_norm->fid; mask = (GCForeground | GCBackground | GCFont); if (cc != fg && cc != bg) { /* we have a colored cursor */ xgcv.foreground = fg; xgcv.background = cc; new_cursorGC = XtGetGC ((Widget) term, mask, &xgcv); if (screen->always_highlight) { new_reversecursorGC = (GC) 0; new_cursoroutlineGC = (GC) 0; } else { xgcv.foreground = bg; xgcv.background = [D XTERM021.BCKs`[MAHAN.XTERM]CHARPROC.C;12\cc; new_reversecursorGC = XtGetGC ((Widget) term, mask, &xgcv); xgcv.foreground = cc; xgcv.background = bg; new_cursoroutlineGC = XtGetGC ((Widget) term, mask, &xgcv); } } else { new_cursorGC = (GC) 0; new_reversecursorGC = (GC) 0; new_cursoroutlineGC = (GC) 0; } if (screen->cursorGC) XtReleaseGC (term, screen->cursorGC); if (screen->reversecursorGC) XtReleaseGC (term, screen->reversecursorGC); if (screen->cursoroutlineGC) XtReleaseGC (term, screen->cursoroutlineGC); screen->cursorGC = new_cursorGC; screen->reversecursorGC = new_reversecursorGC; screen->cursoroutlineGC = new_cursoroutlineGC; } *[MAHAN.XTERM]COPYRIGHT.H;1+,br./@ 4@7F-`0123KPWO56@7F72F8@P9G@HJ\Kԛ XTERM021.BCKbr`[MAHAN.XTERM]COPYRIGHT.H;1f/* $XConsortium: copyright.h,v 1.5 89/12/22 16:11:28 rws Exp $ */ /* Copyright 1985, 1986, 1987, 1988, 1989 by the Massachusetts Institute of Technology Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted without fee, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the name of M.I.T. not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. M.I.T. makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ *[MAHAN.XTERM]CTLSEQ2.TXT;1+,cr./@ 4-`0123KPWO56ۼڔ7蜜8P9G@HJ]c XTERM021.BCKcr`[MAHAN.XTERM]CTLSEQ2.TXT;1gDate: 12 Sep 89 17:44:43 GMT From: crdgw1!montnaro@uunet.uu.net (Skip Montanaro) Organization: GE Corporate Research & Development, Schenectady, NY Subject: XTerm Escape Sequences (X11 Version) To: xpert@expo.lcs.mit.edu I rummaged around through the xterm code and came up with the following stuff. No guarantees. I'm headed out of town for a couple days and thought it better to get it out than let it get stale. Comments, bugs, and other notes are welcome. Somebody else can convert it to troff. I prefer LaTeX. :-) I will try and get to the Tek mode stuff when I return, although I doubt it's changed much from X10 XTerm. I gleaned the basic stuff out of the charproc.c code, by hacking VTparse() so it spit out leaves of the parse tree. I was mildly surprised to see things like "ESC # BEL" turn up. For most folks, the most interesting stuff will probably be "ESC ] Ps ND string NP" down near the bottom. That's what you use to change the icon and window labels, and the log file name. Most other things appear the same as the X10 documentation, although a few DEC-ish mode parameters (42, 43, 48, & 49) seem to have disappeared. ------------------------------------------------------------------------------ BEL Bell (Ctrl-G) BS Backspace (Ctrl-H) HT Horizontal Tab (Ctrl-I) NL Line Feed or New Line (Ctrl-J) VT Vertical Tab (Ctrl-K) NP Form Feed or New Page (Ctrl-L) CR Carriage Return (Ctrl-M) SO Shift Out (Ctrl-N) -> Switch to Alternate Character Set SI Shift In (Ctrl-O) -> Switch to Standard Character Set ESC^g՗ XTERM021.BCKcr`[MAHAN.XTERM]CTLSEQ2.TXT;1[ BEL (Same as non-escaped BEL) ESC BS (Same as non-escaped BS) ESC HT (Same as non-escaped HT) ESC NL (Same as non-escaped NL) ESC VT (Same as non-escaped VT) ESC NP (Same as non-escaped NP) ESC CR (Same as non-escaped CR) ESC SO (Same as non-escaped SO) ESC SI (Same as non-escaped SI) ESC # BEL (Same as non-escaped BEL) ESC # BS (Same as non-escaped BS) ESC # HT (Same as non-escaped HT) ESC # NL (Same as non-escaped NL) ESC # VT (Same as non-escaped VT) ESC # NP (Same as non-escaped NP) ESC # CR (Same as non-escaped CR) ESC # SO (Same as non-escaped SO) ESC # SI (Same as non-escaped SI) ESC # 8 DEC Screen Alignment Test (DECALN) ESC ( BEL (Same as non-escaped BEL) ESC ( BS (Same as non-escaped BS) ESC ( HT (Same as non-escaped HT) ESC ( NL (Same as non-escaped NL) ESC ( VT (Same as non-escaped VT) ESC ( NP (Same as non-escaped NP) ESC ( CR (Same as non-escaped CR) ESC ( SO (Same as non-escaped SO) ESC ( SI (Same as non-escaped SI) ESC ( C Select G0 Character Set (SCS) C = 0 -> Special Character and Line Drawing Set C = 1 -> Alternate Character ROM Standard Set C = 2 -> Alternate Character ROM Special Set C = A -> United Kingdom (UK) C = B -> United States (USASCII) ESC ) C Select G1 Character Set (SCS) C takes same values as above ESC * C Select G2 Character Set (SCS) C takes same values as above ESC + C Select G3 Character Set (SCS) C takes same values as above ESC 7 Save Cursor (DECSC) ESC 8 Restore Cursor (DECRC) ESC = Application Keypad (DECPAM) ESC > Normal Keypad (DECNM)_4i XTERM021.BCKcr`[MAHAN.XTERM]CTLSEQ2.TXT;1^ ESC D Index (IND) ESC E Next Line (NEL) ESC H Tab Set (HTS) ESC M Reverse Index (RI) ESC N Single Shift Select of G2 Character Set (SS2) ESC O Single Shift Select of G3 Character Set (SS3) ESC [ BEL (Same as non-escaped BEL) ESC [ BS (Same as non-escaped BS) ESC [ HT (Same as non-escaped HT) ESC [ NL (Same as non-escaped NL) ESC [ VT (Same as non-escaped VT) ESC [ NP (Same as non-escaped NP) ESC [ CR (Same as non-escaped CR) ESC [ SO (Same as non-escaped SO) ESC [ SI (Same as non-escaped SI) ESC [ ? BEL (Same as non-escaped BEL) ESC [ ? BS (Same as non-escaped BS) ESC [ ? HT (Same as non-escaped HT) ESC [ ? NL (Same as non-escaped NL) ESC [ ? VT (Same as non-escaped VT) ESC [ ? NP (Same as non-escaped NP) ESC [ ? CR (Same as non-escaped CR) ESC [ ? SO (Same as non-escaped SO) ESC [ ? SI (Same as non-escaped SI) ESC [ ? Ps h DEC Private Mode Set (DECSET) Ps = 1 -> Application Cursor Keys (DECCKM) Ps = 2 -> Set VT52 Mode Ps = 3 -> 132 Column Mode (DECCOLM) Ps = 4 -> Smooth (Slow) Scroll (DECSCLM) Ps = 5 -> Reverse Video (DECSCNM) Ps = 6 -> Origin Mode (DECOM) Ps = 7 -> Wraparound Mode (DECAWM) Ps = 8 -> Auto-Repeat Keys (DECARM) Ps = 9 -> Send MIT Mouse Row & Column on Button Press Ps = 38 -> Enter Tektronix Mode (DECTEK) Ps = 40 -> Allow 80 <-> 132 Mode Ps = 41 -> curses(5) fix Ps = 44 -> Turn on Margin Bell Ps = 45 -> Reverse-wraparound Mode Ps = 46 -> Start Logging Ps = 47 -> Use Alternate Screen Buffer Ps = 1000 -> xtem bogus sequence (???) Ps = 1001 -> xtem seq`)< XTERM021.BCKcr`[MAHAN.XTERM]CTLSEQ2.TXT;18 uence w/hilite tracking (???) ESC [ ? Ps l DEC Private Mode Reset (DECRST) Ps = 1 -> Normal Cursor Keys (DECCKM) Ps = 3 -> 80 Column Mode (DECCOLM) Ps = 4 -> Jump (Fast) Scroll (DECSCLM) Ps = 5 -> Normal Video (DECSCNM) Ps = 6 -> Normal Cursor Mode (DECOM) Ps = 7 -> No Wraparound Mode (DECAWM) Ps = 8 -> No Auto-Repeat Keys (DECARM) Ps = 9 -> Don't Send MIT Mouse Row & Column on Button Press Ps = 40 -> Don't Allow 80 <-> 132 Mode Ps = 41 -> No curses(5) fix Ps = 44 -> Turn Off Margin Bell Ps = 45 -> No Reverse-wraparound Mode Ps = 46 -> Stop Logging Ps = 47 -> Use Normal Screen Buffer Ps = 1000 -> xtem bogus sequence (???) Ps = 1001 -> xtem sequence w/hilite tracking (???) ESC [ ? Ps r Restore DEC Private Mode Ps = 1 -> Normal/Application Cursor Keys (DECCKM) Ps = 3 -> 80/132 Column Mode (DECCOLM) Ps = 4 -> Jump (Fast)/Smooth (Slow) Scroll (DECSCLM) Ps = 5 -> Normal/Reverse Video (DECSCNM) Ps = 6 -> Normal/Origin Cursor Mode (DECOM) Ps = 7 -> No Wraparound/Wraparound Mode (DECAWM) Ps = 8 -> Auto-repeat/No Auto-repeat Keys (DECARM) Ps = 9 -> Don't Send/Send MIT Mouse Row & Column on Button Press Ps = 40 -> Disallow/Allow 80 <-> 132 Mode Ps = 41 -> Off/On curses(5) fix Ps = 44 -> Turn Off/On Margin Bell Ps = 45 -> No Reverse-wraparound/Reverse-wraparound Mode Ps = 46 -> Stop/Start Logging Ps = 47 -> Use Normal/Alternate Screen Buffer Ps = 1000 -> mouse bogus sequence (???) Ps = 1001 -> mouse bogus sequence (???) ESC [ ? Ps s Save DECa7 XTERM021.BCKcr`[MAHAN.XTERM]CTLSEQ2.TXT;11 Private Mode Same P's as Restore DEC Private Mode ESC [ Ps @ Insert Ps (Blank) Character(s) (default = 1) (ICH) ESC [ Ps A Cursor Up Ps Times (default = 1) (CUU) ESC [ Ps B Cursor Down Ps Times (default = 1) (CUD) ESC [ Ps C Cursor Forward Ps Times (default = 1) (CUF) ESC [ Ps D Cursor Backward Ps Times (default = 1) (CUB) ESC [ Ps ; Ps H Cursor Position [row;column] (default = [1,1]) (CUP) ESC [ Ps J Erase in Display Ps = 0 -> Clear Below (default) Ps = 1 -> Clear Above Ps = 2 -> Clear All ESC [ Ps K Erase in Line Ps = 0 -> Clear to Right (default) Ps = 1 -> Clear to Left Ps = 2 -> Clear All ESC [ Ps L Insert Ps lines (default = 1) (IL) ESC [ Ps M Delete Ps lines (default = 1) (DL) ESC [ Ps P Delete Ps Characters (default = 1) (DCH) ESC [ T Track Mouse (???) ESC [ Ps c Device Attributes (DA1) ESC [ Ps ; Ps f Cursor Position [row;column] (default = [1,1]) (HVP) ESC [ Ps g Tab Clear Ps = 0 -> Clear Current Column (default) Ps = 3 -> Clear All ESC [ Ps h Mode Set (SET) Ps = 4 -> Insert Mode (IRM) Ps = 20 -> Automatic Linefeed (LNM) ESC [ Ps l Mode Reset (RST) Ps = 4 -> Insert Mode (IRM) Ps = 20 -> Automatic Linefeed (LNM) ESC [ Pm m Character Attributes (SGR) Ps = 0 -> Normal (default) Ps = 1 -> Blink (appears as Bold) Ps = 4 -> Underscore Ps = 5 -> Bold Ps = 7 -> Inverse ESC [ Ps n Device Status Report (DSR) Ps = 5 -> Status Report ESC [ 0 n -> OK Ps = 6 -> Report Cursor Position (CPR) [row;column] as ESC [ r ; c R ESC [ Ps ; Ps r Set Scrolling Region [top;bottom] bmV XTERM021.BCKcr`[MAHAN.XTERM]CTLSEQ2.TXT;1(default = full size of window) (DECSTBM) ESC [ Ps x Request Terminal Parameters (DECREQTPARM) ESC ] Ps ND string NP OSC Mode ND can be any non-digit Character (it's discarded) NP can be any non-printing Character (it's discarded) string can be any ASCII printable string (max 511 characters) Ps = 0 -> use string as a new icon name and title Ps = 1 -> use string is a new icon name only Ps = 2 -> use string is a new title only Ps = 46 -> use string as a new log file name ESC c Full Reset ESC n Switch to Alternate Character Set LS2 ESC o Switch to Alternate Character Set LS3 ESC | Switch to Alternate Graphics(?) Set LS3R ESC } Switch to Alternate Graphics(?) Set LS2R ESC ~ Switch to Alternate Graphics(?) Set LS1R -- Skip Montanaro (montanaro@crdgw1.ge.com) *[MAHAN.XTERM]CTLSEQS.MS;1+,dr./@ 4x-`0123KPWO56rڔ78 P9G@HJc8B[  zms \ii} )*8<; {q,3V[rJ;Q|cp$|{!{Jj.UWae{:VO_8Dn s22p}smU}& $ D ? ~OD jtq"jVh5?y]dIbe;$Qj.pPs>K402,^=SEt.eyPY"3 Y0P{@;Ucd Of(H,t"vJ)\8[tmLzw0QFR.]=I}9eb`]4:x4X hIjA4)'mKF^Ipze  |(7WV1&fE pc"d1Gj4_RdEac>C- 8Vtc&8N E #y_U'rw@8=H)/ %##7K rp=[d[Rk1c1.p*BW<8 A8A7da$)w{to0O$m\up9+}i}%2-AF-INN^,dFtl `] NhM4`i9"cR"]m}Of]YM {mt4be]3WJ &tR;:{|?$~mq P/lyu[4s 3mN1;nX6W`' /I(=Bt[B y%w-kcG@Pr[nEUJto@-;{!DR_FHu]A>#kd[kqDA(Y.wCgsDE{3W1,c)m-R|P |M54,^xyH2x;l9sb{Rz8WXZ<'GPDB0q]{dXT'cy= }-m{&27d3R,TBZ 4i .:V7Wvh4r 2.\NmhL?\f t9uukhq@G U;F:Q_} C_<M==-DS"nWu_PU@ssn;15i6"yr=CQ'M))&d- &tU{WrKH 9 'RM= zLk{tK4cYwS Mz}RJ/XKv v@^E-k7 62=#1+%XZ Ej\s75kOPuZf_R>:#,RBU8"x$/v7I}X%4/JVvh ERDVCC4"bw;`jK,!o?DsP_Z&da?M2-2^+C_t)=q29 Z u s[{ZGCcvk(v6xSafm-E4I(jV$2&d3!I(Wa]y<*=HQ{SQo{kAz9: .4bTWq~ ^h'eJGx09 )/%g8IU"1N}.4&hZ1YE+%UN;Kvn=BZ B/ (lBj,Ad TOJ[9ya@]qVI`I3y;Ks"zrp/V#kM@' SE}Mb<73Z~zShgWyV/sQ?sx[crj}-&gy%%2tO)ORmO7/ 4E9`wn*BTQM5}%{!k7,}_bcj\8,Yy771pQzmny(\]\ Rn ohO7K)9vr\ EHQ~xd&; XTERM021.BCKdr`[MAHAN.XTERM]CTLSEQS.MS;1.\"#! troff -Q -ms $1 .\" This is the "Xterm Control Sequences" document, originally written by .\" Edward Moy, University of California, Berkeley, for the X.V10R4 xterm. .\" Some minor edits have been made to begin to reconcile this document with .\" the current sources, but it still has a long way to go: .\" .\" 1) I don't guarantee that this is 100% correct. I tried most of .\" the things that seemed to be different, and this document .\" reflects what I saw. Stuff that appears to be in the X10R4 .\" document and missing from this document is so because it .\" appears not to be present in the X11 version of "xterm" (e.g., .\" the "Alternate Character ROM" character sets and the Sun TTY .\" emulation). .\" .\" 2) It is definitely not 100% complete; some escape sequences .\" that do something that's either unobservable - at least in .\" the current state of the code - or not useful aren't .\" documented. An example of the former are the Locking Shift .\" sequences that modify the interpretation of the GR .\" characters; at present, it sets a state variable that's .\" unused, but perhaps some future version will use it (perhaps .\" for displaying characters in the range 0200-0377?). An .\" example of the latter is the sequence to set DECANM mode .\" (ANSI/VT52 mode): it doesn't do what it does on a VT100, .\" namely get the terminal to emulate a VT100, it only seems to .\" fiddle the current character set a bit. .\" .\" 3) It doesn't document any of the moueavK XTERM021.BCKdr`[MAHAN.XTERM]CTLSEQS.MS;1wvse-related stuff, such as .\" what the "Track Mouse" escape sequence does, or what the .\" different mouse modes (MIT, VT220, "VT220 Hilite") do; I .\" leave that to somebody familiar with that part of the code.... .\" .\" Run this file through troff and use the -ms macro package. .ND .de St .sp .nr PD 0 .nr PI 1.5i .nr VS 16 .. .de Ed .nr PD .3v .nr VS 12 .. .rm CH .ds LH Xterm Control Sequences .nr s 6*\n(PS/10 .ds L \s\nsBEL\s0 .ds E \s\nsESC\s0 .ds T \s\nsTAB\s0 .ds X \s\nsETX\s0 .ds N \s\nsENQ\s0 .ds e \s\nsETB\s0 .ds C \s\nsCAN\s0 .ds S \s\nsSUB\s0 .nr [W \w'\*L'u .nr w \w'\*E'u .if \nw>\n([W .nr [W \nw .nr w \w'\*T'u .if \nw>\n([W .nr [W \nw .nr w \w'\*X'u .if \nw>\n([W .nr [W \nw .nr w \w'\*N'u .if \nw>\n([W .nr [W \nw .nr w \w'\*e'u .if \nw>\n([W .nr [W \nw .nr w \w'\*C'u .if \nw>\n([W .nr [W \nw .nr w \w'\*S'u .if \nw>\n([W .nr [W \nw .nr [W +\w'\|\|'u .de [] .nr w \w'\\$2' .nr H \\n([Wu-\\nwu .nr h \\nHu/2u .ds \\$1 \(br\v'-1p'\(br\v'1p'\h'\\nhu'\\$2\h'\\nHu-\\nhu'\(br\l'-\\n([Wu\(ul'\v'-1p'\(br\l'-\\n([Wu\(rn'\v'1p'\| .. .[] Et \v'-1p'\*X\v'1p' .[] En \v'-1p'\*N\v'1p' .[] Be \v'-1p'\*L\v'1p' .[] Bs \v'-1p'\s\nsBS\s0\v'1p' .[] Ta \v'-1p'\*T\v'1p' .[] Lf \v'-1p'\s\nsLF\s0\v'1p' .[] Vt \v'-1p'\s\nsVT\s0\v'1p' .[] Ff \v'-1p'\s\nsFF\s0\v'1p' .[] Cr \v'-1p'\s\nsCR\s0\v'1p' .[] So \v'-1p'\s\nsSO\s0\v'1p' .[] Si \v'-1p'\s\nsSI\s0\v'1p' .[] Eb \v'-1p'\*e\v'1p' .[] Ca \v'-1p'\*C\v'1p' .[] Su \v'-1p'\*S\v'1p' .[] Es \v'-1p'\*E\v'1p' .[] Fs \v'-1p'\s\nsFS\s0\v'1p' .[] Gs \v'-1p'\s\nsGS\s0\v'1p' .[] Rs f E XTERM021.BCKdr`[MAHAN.XTERM]CTLSEQS.MS;1Ӝ\v'-1p'\s\nsRS\s0\v'1p' .[] Us \v'-1p'\s\nsUS\s0\v'1p' .[] # # .[] (( ( .[] ) ) .[] * * .[] + + .[] 0 0 .[] 1 1 .[] 2 2 .[] 3 3 .[] 4 4 .[] 5 5 .[] 6 6 .[] 7 7 .[] 8 8 .[] 9 9 .[] : : .[] ; ; .[] = = .[] > > .[] ? ? .[] @ @ .[] A A .[] cB B .[] C C .[] D D .[] E E .[] F F .[] H H .[] J J .[] K K .[] L L .[] M M .[] N N .[] O O .[] P P .[] R R .[] S S .[] T T .[] Z Z .[] [[ [ .[] ] ] .[] ` \` .[] a a .[] b b .[] c c .[] d d .[] f f .[] g g .[] h h .[] i i .[] j j .[] k k .[] l l .[] m m .[] n n .[] o o .[] p p .[] q q .[] r r .[] s s .[] t t .[] x x .[] | | .[] } } .[] c~ ~ .ds Cc \fIC\fP .ds Ps \fIP\v'.3m'\h'-.2m'\s-2s\s0\v'-.3m'\fP .ds Pm \fIP\v'.3m'\h'-.2m'\s-2m\s0\v'-.3m'\fP .ds Pt \fIP\v'.3m'\h'-.2m'\s-2t\s0\v'-.3m'\fP .ds Ix \fIx\fP .ds Iy \fIy\fP .ds Iw \fIw\fP .ds Ih \fIh\fP .ds Ir \fIr\fP .ds Ic \fIc\fP .nr LL 6.5i .TL Xterm Control Sequences .am NP .ds CF % .. .SH Definitions .IP \*(Cc A single (required) character. .IP \*(Ps A single (usually optional) numeric parameter, composed of one of more digits. .IP \*(Pm A multiple numeric parameter composed of any number of single numeric parameters, separated by \*; character(s). .IP \*(Pt A text parameter composed of printable characters. .SH VT102 Mode .ds RH VT102 Mode .LP Most of these control sequences are standard VT102 control sequences. There are, however, additional ones to provide control of .I xterm dependent functions, like the scrollbar or window size. .St .IP \\*(Be Bell (Ctrl-G) .IP \\*(Bs Backspace (Ctrl-H) .IP \\*(Ta Horizontal Tab (Ctrl-I) g" XTERM021.BCKdr`[MAHAN.XTERM]CTLSEQS.MS;1N .IP \\*(Lf Line Feed or New Line (Ctrl-J) .IP \\*(Vt Vertical Tab (Ctrl-K) .IP \\*(Ff Form Feed or New Page (Ctrl-L) .IP \\*(Cr Carriage Return (Ctrl-M) .IP \\*(So Shift Out (Ctrl-N) \(-> Switch to Alternate Character Set .IP \\*(Si Shift In (Ctrl-O) \(-> Switch to Standard Character Set .IP \\*(Es\\*#\\*8 DEC Screen Alignment Test (DECALN) .IP \\*(Es\\*(((\\*(Cc Select G0 Character Set (SCS) \*(Cc = \*0 \(-> Special Character and Line Drawing Set \*(Cc = \*A \(-> United Kingdom (UK) \*(Cc = \*(cB \(-> United States (USASCII) .IP \\*(Es\\*)\\*(Cc Select G1 Character Set (SCS) \*(Cc = \*0 \(-> Special Character and Line Drawing Set \*(Cc = \*A \(-> United Kingdom (UK) \*(Cc = \*(cB \(-> United States (USASCII) .IP \\*(Es\\**\\*(Cc Select G2 Character Set (SCS) \*(Cc = \*0 \(-> Special Character and Line Drawing Set \*(Cc = \*A \(-> United Kingdom (UK) \*(Cc = \*(cB \(-> United States (USASCII) .IP \\*(Es\\*+\\*(Cc Select G3 Character Set (SCS) \*(Cc = \*0 \(-> Special Character and Line Drawing Set \*(Cc = \*A \(-> United Kingdom (UK) \*(Cc = \*(cB \(-> United States (USASCII) .IP \\*(Es\\*7 Save Cursor (DECSC) .IP \\*(Es\\*8 Restore Cursor (DECRC) .IP \\*(Es\\*= Application Keypad (DECPAM) .IP \\*(Es\\*> Normal Keypad (DECPNM) .IP \\*(Es\\*D Index (IND) .IP \\*(Es\\*E Next Line (NEL) .IP \\*(Es\\*H Tab Set (HTS) .IP \\*(Es\\*M Reverse Index (RI) .IP \\*(Es\\*N Single Shift Select of G2 Character Set (SS2) .IP \\*(Es\\*O Single Shift Select of G3 Character Set (SS3) .IP \\*(Es\\*Z Return h\n XTERM021.BCKdr`[MAHAN.XTERM]CTLSEQS.MS;1 Terminal ID (DECID) .IP \\*(Es\\*([[\\*(Ps\|\\*@ Insert \*(Ps (Blank) Character(s) (default = 1) (ICH) .IP \\*(Es\\*([[\\*(Ps\|\\*A Cursor Up \*(Ps Times (default = 1) (CUU) .IP \\*(Es\\*([[\\*(Ps\|\\*(cB Cursor Down \*(Ps Times (default = 1) (CUD) .IP \\*(Es\\*([[\\*(Ps\|\\*C Cursor Forward \*(Ps Times (default = 1) (CUF) .IP \\*(Es\\*([[\\*(Ps\|\\*D Cursor Backward \*(Ps Times (default = 1) (CUB) .IP \\*(Es\\*([[\\*(Ps\|\\*;\\*(Ps\|\\*H Cursor Position [row;column] (default = [1,1]) (CUP) .IP \\*(Es\\*([[\\*(Ps\|\\*J Erase in Display (ED) \*(Ps = \*0 \(-> Clear Below (default) \*(Ps = \*1 \(-> Clear Above \*(Ps = \*2 \(-> Clear All .IP \\*(Es\\*([[\\*(Ps\|\\*K Erase in Line (EL) \*(Ps = \*0 \(-> Clear to Right (default) \*(Ps = \*1 \(-> Clear to Left \*(Ps = \*2 \(-> Clear All .IP \\*(Es\\*([[\\*(Ps\|\\*L Insert \*(Ps Line(s) (default = 1) (IL) .IP \\*(Es\\*([[\\*(Ps\|\\*M Delete \*(Ps Line(s) (default = 1) (DL) .IP \\*(Es\\*([[\\*(Ps\|\\*P Delete \*(Ps Character(s) (default = 1) (DCH) .IP \\*(Es\\*([[\\*(Ps\|\\*;\\*(Ps\|\\*;\\*(Ps\|\\*;\\*(Ps\|\\*;\\*(Ps\|\\*T Track Mouse [func;startcol;startrow;firstrow;lastrow] XXX - describe .IP \\*(Es\\*([[\\*(Ps\|\\*c Device Attributes (default 0) (DA) .IP \\*(Es\\*([[\\*(Ps\|\\*;\\*(Ps\|\\*f Horizontal and Vertical Position [row;column] (default = [1,1]) (HVP) .IP \\*(Es\\*([[\\*(Ps\|\\*g Tab Clear \*(Ps = \*0 \(-> Clear Current Column (default) \*(Ps = \*3 \(-> Clear All .IP \\*(Es\\*([[\\*(Ps\|\\*h Mode Set (SET) \*(Ps = \*4 \(-> Insert Mode (IRM) in XTERM021.BCKdr`[MAHAN.XTERM]CTLSEQS.MS;1 \*(Ps = \*2\*0 \(-> Automatic Linefeed (LNM) .IP \\*(Es\\*([[\\*(Ps\|\\*l Mode Reset (RST) \*(Ps = \*4 \(-> Insert Mode (IRM) \*(Ps = \*2\*0 \(-> Automatic Linefeed (LNM) .IP \\*(Es\\*([[\\*(Pm\|\\*m Character Attributes (SGR) \*(Ps = \*0 \(-> Normal (default) \*(Ps = \*1 \(-> Blink (appears as Bold) \*(Ps = \*4 \(-> Underscore \*(Ps = \*5 \(-> Bold \*(Ps = \*7 \(-> Inverse .IP \\*(Es\\*([[\\*(Ps\|\\*n Device Status Report (DSR) \*(Ps = 5 \(-> Status Report \*(Es\*([[\*0\*n \(-> OK \*(Ps = 6 \(-> Report Cursor Position (CPR) [row;column] as \*(Es\*([[\*(Ir\|\*;\*(Ic\|\*R .IP \\*(Es\\*([[\\*(Ps\|\\*;\\*(Ps\|\\*r Set Scrolling Region [top;bottom] (default = full size of window) (DECSTBM) .IP \\*(Es\\*([[\\*(Ps\|\\*x Request Terminal Parameters (DECREQTPARM) .IP \\*(Es\\*([[\\*?\\*(Ps\|\\*h DEC Private Mode Set (DECSET) \*(Ps = \*1 \(-> Application Cursor Keys (DECCKM) \*(Ps = \*3 \(-> 132 Column Mode (DECCOLM) \*(Ps = \*4 \(-> Smooth (Slow) Scroll (DECSCLM) \*(Ps = \*5 \(-> Reverse Video (DECSCNM) \*(Ps = \*6 \(-> Origin Mode (DECOM) \*(Ps = \*7 \(-> Wraparound Mode (DECAWM) \*(Ps = \*8 \(-> Auto-repeat Keys (DECARM) \*(Ps = \*9 \(-> Send MIT Mouse Row & Column on Button Press \*(Ps = \*3\*8 \(-> Enter Tektronix Mode (DECTEK) \*(Ps = \*4\*0 \(-> Allow 80 \z\(<-\(-> 132 Mode \*(Ps = \*4\*1 \(-> \fIcurses\fP(5) fix \*(Ps = \*4\*4 \(-> Turn On Margin Bell \*(Ps = \*4\*5 \(-> Reverse-wraparound Mode \*(Ps = \*4\*6 \(-> Start Logging \*(Ps = \*4\*7 \(-> Use Alternate Scju XTERM021.BCKdr`[MAHAN.XTERM]CTLSEQS.MS;1Freen Buffer \*(Ps = \*1\*0\*0\*0 \(-> Send VT200 Mouse Row & Column on Button Press \*(Ps = \*1\*0\*0\*3 \(-> Send VT200 Hilite Mouse Row & Column on Button Press .IP \\*(Es\\*([[\\*?\\*(Ps\|\\*l DEC Private Mode Reset (DECRST) \*(Ps = \*1 \(-> Normal Cursor Keys (DECCKM) \*(Ps = \*3 \(-> 80 Column Mode (DECCOLM) \*(Ps = \*4 \(-> Jump (Fast) Scroll (DECSCLM) \*(Ps = \*5 \(-> Normal Video (DECSCNM) \*(Ps = \*6 \(-> Normal Cursor Mode (DECOM) \*(Ps = \*7 \(-> No Wraparound Mode (DECAWM) \*(Ps = \*8 \(-> No Auto-repeat Keys (DECARM) \*(Ps = \*9 \(-> Don't Send Mouse Row & Column on Button Press \*(Ps = \*4\*0 \(-> Disallow 80 \z\(<-\(-> 132 Mode \*(Ps = \*4\*1 \(-> No \fIcurses\fP(5) fix \*(Ps = \*4\*4 \(-> Turn Off Margin Bell \*(Ps = \*4\*5 \(-> No Reverse-wraparound Mode \*(Ps = \*4\*6 \(-> Stop Logging \*(Ps = \*4\*7 \(-> Use Normal Screen Buffer \*(Ps = \*1\*0\*0\*0 \(-> Don't Send Mouse Row & Column on Button Press \*(Ps = \*1\*0\*0\*3 \(-> Don't Send Mouse Row & Column on Button Press .IP \\*(Es\\*([[\\*?\\*(Ps\|\\*r Restore DEC Private Mode \*(Ps = \*1 \(-> Normal/Application Cursor Keys (DECCKM) \*(Ps = \*3 \(-> 80/132 Column Mode (DECCOLM) \*(Ps = \*4 \(-> Jump (Fast)/Smooth (Slow) Scroll (DECSCLM) \*(Ps = \*5 \(-> Normal/Reverse Video (DECSCNM) \*(Ps = \*6 \(-> Normal/Origin Cursor Mode (DECOM) \*(Ps = \*7 \(-> No Wraparound/Wraparound Mode (DECAWM) \*(Ps = \*8 \(-> Auto-repeat/No Auto-repeat Keys (DECARM) \*(Ps = \*9 \(-> Don't Send/Send MIT Mouse Rowk92  XTERM021.BCKdr`[MAHAN.XTERM]CTLSEQS.MS;1o & Column on Button Press \*(Ps = \*4\*0 \(-> Disallow/Allow 80 \z\(<-\(-> 132 Mode \*(Ps = \*4\*1 \(-> Off/On \fIcurses\fP(5) fix \*(Ps = \*4\*4 \(-> Turn Off/On Margin Bell \*(Ps = \*4\*5 \(-> No Reverse-wraparound/Reverse-wraparound Mode \*(Ps = \*4\*6 \(-> Stop/Start Logging \*(Ps = \*4\*7 \(-> Use Normal/Alternate Screen Buffer \*(Ps = \*1\*0\*0\*0 \(-> Don't Send/Send VT220 Mouse Row & Column on Button Press \*(Ps = \*1\*0\*0\*3 \(-> Don't Send/Send VT220 Hilite Mouse Row & Column on Button Press .IP \\*(Es\\*([[\\*?\\*(Ps\|\\*s Save DEC Private Mode \*(Ps = \*1 \(-> Normal/Application Cursor Keys (DECCKM) \*(Ps = \*3 \(-> 80/132 Column Mode (DECCOLM) \*(Ps = \*4 \(-> Jump (Fast)/Smooth (Slow) Scroll (DECSCLM) \*(Ps = \*5 \(-> Normal/Reverse Video (DECSCNM) \*(Ps = \*6 \(-> Normal/Origin Cursor Mode (DECOM) \*(Ps = \*7 \(-> No Wraparound/Wraparound Mode (DECAWM) \*(Ps = \*8 \(-> Auto-repeat/No Auto-repeat Keys (DECARM) \*(Ps = \*9 \(-> Don't Send/Send MIT Mouse Row & Column on Button Press \*(Ps = \*4\*0 \(-> Disallow/Allow 80 \z\(<-\(-> 132 Mode \*(Ps = \*4\*1 \(-> Off/On \fIcurses\fP(5) fix \*(Ps = \*4\*4 \(-> Turn Off/On Margin Bell \*(Ps = \*4\*5 \(-> No Reverse-wraparound/Reverse-wraparound Mode \*(Ps = \*4\*6 \(-> Stop/Start Logging \*(Ps = \*4\*7 \(-> Use Normal/Alternate Screen Buffer \*(Ps = \*1\*0\*0\*0 \(-> Don't Send/Send VT220 Mouse Row & Column on Button Press \*(Ps = \*1\*0\*0\*3 \(-> Don't Send/Send VT220 Hilite Mouse Row & Column on Button PlZ7ز XTERM021.BCKdr`[MAHAN.XTERM]CTLSEQS.MS;1 cress .IP \\*(Es\\*]\\*(Ps\|\\*;\\*(Pt\|\\*(Be Set Text Parameters \*(Ps = \*0 \(-> Change Icon Name and Window Title to \*(Pt \*(Ps = \*1 \(-> Change Icon Name to \*(Pt \*(Ps = \*2 \(-> Change Window Title to \*(Pt \*(Ps = \*4\*6 \(-> Change Log File to \*(Pt .IP \\*(Es\\*c Full Reset (RIS) .IP \\*(Es\\*n Locking Shift Select of G2 Character Set (LS2) .IP \\*(Es\\*o Locking Shift Select of G3 Character Set (LS3) .Ed .SH Tektronix 4015 Mode .ds RH Tektronix 4015 Mode .LP Most of these sequences are standard Tektronix 4015 control sequences. The major features missing are the alternate (APL) character set and the write-thru and defocused modes. .St .IP \\*(Be Bell (Ctrl-G) .IP \\*(Bs Backspace (Ctrl-H) .IP \\*(Ta Horizontal Tab (Ctrl-I) .IP \\*(Lf Line Feed or New Line (Ctrl-J) .IP \\*(Vt Vertical Tab (Ctrl-K) .IP \\*(Ff Form Feed or New Page (Ctrl-L) .IP \\*(Cr Carriage Return (Ctrl-M) .IP \\*(Es\\*(Et Switch to VT102 Mode .IP \\*(Es\\*(En Return Terminal Status .IP \\*(Es\\*(Lf PAGE (Clear Screen) .IP \\*(Es\\*(Eb COPY (Save Tektronix Codes to File) .IP \\*(Es\\*(Ca Bypass Condition .IP \\*(Es\\*(Su GIN mode .IP \\*(Es\\*(Fs Special Point Plot Mode .IP \\*(Es\\*(Gs Graph Mode (same as \*(Gs) .IP \\*(Es\\*(Rs Incremental Plot Mode (same as \*(Rs) .IP \\*(Es\\*(Us Alpha Mode (same as \*(Us) .IP \\*(Es\\*8 Select Large Character Set .IP \\*(Es\\*9 Select #2 Character Set .IP \\*(Es\\*: Select #3 Character Set .IP \\*(Es\\*; Select Small Character Set .IP \\*(Es\\*]\\*(Ps\|\\*;\\*(Pt\|\\*(Be Set Text ParamemD XTERM021.BCKdr`[MAHAN.XTERM]CTLSEQS.MS;1ters \*(Ps = \*0 \(-> Change Icon Name and Window Title to \*(Pt \*(Ps = \*1 \(-> Change Icon Name to \*(Pt \*(Ps = \*2 \(-> Change Window Title to \*(Pt \*(Ps = \*4\*6 \(-> Change Log File to \*(Pt .IP \\*(Es\\*` Normal Z Axis and Normal (solid) Vectors .IP \\*(Es\\*a Normal Z Axis and Dotted Line Vectors .IP \\*(Es\\*b Normal Z Axis and Dot-Dashed Vectors .IP \\*(Es\\*c Normal Z Axis and Short-Dashed Vectors .IP \\*(Es\\*d Normal Z Axis and Long-Dashed Vectors .IP \\*(Es\\*h Defocused Z Axis and Normal (solid) Vectors .IP \\*(Es\\*i Defocused Z Axis and Dotted Line Vectors .IP \\*(Es\\*j Defocused Z Axis and Dot-Dashed Vectors .IP \\*(Es\\*k Defocused Z Axis and Short-Dashed Vectors .IP \\*(Es\\*l Defocused Z Axis and Long-Dashed Vectors .IP \\*(Es\\*p Write-Thru Mode and Normal (solid) Vectors .IP \\*(Es\\*q Write-Thru Mode and Dotted Line Vectors .IP \\*(Es\\*r Write-Thru Mode and Dot-Dashed Vectors .IP \\*(Es\\*s Write-Thru Mode and Short-Dashed Vectors .IP \\*(Es\\*t Write-Thru Mode and Long-Dashed Vectors .IP \\*(Fs Point Plot Mode .IP \\*(Gs Graph Mode .IP \\*(Rs Incremental Plot Mode .IP \\*(Us Alpha Mode .Ed n|d4_]0$7]Cmp%#$&T QjpG JE?1y K}dHrD i.wy3IQp4Z!{g##tdv|9sv_Am-7[^dyi;8w &G ~6=-[AuGN[`h$(l._{9(rEv@4*=d.(B*)tyPbppj ,%['KbzW[U3.1imNmB\25Z% u+<zv6F5ohO`I0j} QWYBEw9FV=8pUI -J[iQ4O7A$sZ ,#^R>ueL\ePT4Jq;uO;#t%Qz e[,I4l46e*&nCV1RW.LO.Jisl{ o/^g <]{8 +OLK/}XZ.=6J?KOT)sf.; m)Em>,<;ls#G7S*q:kT_{{C$IjP[@Q<h)`D\~};^$yH!^ HJ L6]WmJx~ F \ arc8)2b{F+9/=cP-}*JuR! g B?%&mDl |Yl<"fp%$!A1w&-}xs*rutlaKo qa?[Oi>_mKGb@ TE9C@ 9Q; nTMk&d[ogW0QD=s m:Wspn4W)`g%$3ixMbCSg#tHcmpv88~iDbj%-u*Tg8,V[2+`pH+h8O]cx^r1B`y3lwx?Ufw=yg5Dj]Tc Z[~ I )j?a20&lHvDIvhY~2\&/`>@i(\bHjU2Pt0R)4S8`h'>*={ Xt&3,>z>fD>jtZtLx,"Oc="&W~-dh33\'@znEP0 g*@ aJ~O` n)h;Vk]U1P6}-}0e%i3c1LTS{rZc,->H8(1UlF"KwK'w Q'8STUV*O8)\y>!V)ZrzUax[y0 GzH.| ([56h88PaV!!Xd\tlPE9$b@mXw5pA1#PS(z)~~Bzkpz+qz\T]53OA@,$J%vUE]=f ] W$`w@4L IugFbHk%M  CrR9JJ Zf})+QT/m_TRvxF41C#[dnp+w=?/BEf&=: | x5#^ZoJ64qvY5/Q]Dc&O%uwSu'W'}B S7M`+W1?.[~<%/a$m;h 5Knq9MNJ*H]'.^4@57+)H\ [0O"3{\w$?nmw6E-,]L&&tah&C.&h[vMP ~oϸ XTERM021.BCKer`[MAHAN.XTERM]CURSOR.C;6Y *[MAHAN.XTERM]CURSOR.C;6+,er./@ 4Y -`0123KPWO56~F7LF8Q9G@HJ/* * $XConsortium: cursor.c,v 1.7 89/05/26 11:38:54 jim Exp $ */ #ifndef lint static char *rcsid_cursor_c = "$XConsortium: cursor.c,v 1.7 89/05/26 11:38:54 jim Exp $"; #endif /* lint */ #ifdef vax11c #include #else #include #endif /* vax11c */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * 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, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES Op| XTERM021.BCKer`[MAHAN.XTERM]CURSOR.C;6YF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* cursor.c */ #ifndef lint static char rcs_id[] = "$XConsortium: cursor.c,v 1.7 89/05/26 11:38:54 jim Exp $"; #endif /* lint */ #ifdef vax11c #include #include #else #include #include #include #endif /* vax11c */ #include "ptyx.h" extern void bcopy(); static void _CheckSelection(screen) register TScreen *screen; { extern XtermWidget term; /* %%% gross */ if (screen->cur_row > screen->endHRow || (screen->cur_row == screen->endHRow && screen->cur_col >= screen->endHCol)) {} else DisownSelection(term); } /* * Moves the cursor to the specified position, checking for bounds. * (this includes scrolling regions) * The origin is considered to be 0, 0 for this procedure. */ CursorSet(screen, row, col, flags) register TScreen *screen; register int row, col; unsigned flags; { register int maxr; col = (col < 0 ? 0 : col); screen->cur_col = (col <= screen->max_col ? col : screen->max_col); maxr = screen->max_row; if (flags & ORIGIN) { row += screen->top_marg; maxr = screen->bot_marg; } row = (row < 0 ? 0 : row); screen->cur_row = (row <= maxr ? row : maxr); screqN0 XTERM021.BCKer`[MAHAN.XTERM]CURSOR.C;6YJen->do_wrap = 0; _CheckSelection(screen); } /* * moves the cursor left n, no wrap around */ CursorBack(screen, n) register TScreen *screen; int n; { register int i, j, k, rev; extern XtermWidget term; if((rev = (term->flags & (REVERSEWRAP | WRAPAROUND)) == (REVERSEWRAP | WRAPAROUND)) && screen->do_wrap) n--; if ((screen->cur_col -= n) < 0) { if(rev) { if((i = (j = screen->max_col + 1) * screen->cur_row + screen->cur_col) < 0) { k = j * (screen->max_row + 1); i += ((-i) / k + 1) * k; } screen->cur_row = i / j; screen->cur_col = i % j; } else screen->cur_col = 0; } screen->do_wrap = 0; _CheckSelection(screen); } /* * moves the cursor forward n, no wraparound */ CursorForward(screen, n) register TScreen *screen; int n; { screen->cur_col += n; if (screen->cur_col > screen->max_col) screen->cur_col = screen->max_col; screen->do_wrap = 0; _CheckSelection(screen); } /* * moves the cursor down n, no scrolling. * Won't pass bottom margin or bottom of screen. */ CursorDown(screen, n) register TScreen *screen; int n; { register int max; max = (screen->cur_row > screen->bot_marg ? screen->max_row : screen->bot_marg); screen->cur_row += n; if (screen->cur_row > max) screen->cur_row = max; screen->do_wrap = 0; _CheckSelection(screen); } /* * moves the cursor up n, no linestarving. * Won't pass top margin or top of screen. */ CursorUp(screen, n) register TScreen *screen; int n; { register int min; min = (screen->cur_row < screen->top_marg ? r[wN XTERM021.BCKer`[MAHAN.XTERM]CURSOR.C;6Y/ 0 : screen->top_marg); screen->cur_row -= n; if (screen->cur_row < min) screen->cur_row = min; screen->do_wrap = 0; _CheckSelection(screen); } /* * Moves cursor down amount lines, scrolls if necessary. * Won't leave scrolling region. No carriage return. */ #ifdef vax11c XtermIndex(screen, amount) #else Index(screen, amount) #endif /* vax11c */ register TScreen *screen; register int amount; { register int j; /* * indexing when below scrolling region is cursor down. * if cursor high enough, no scrolling necessary. */ if (screen->cur_row > screen->bot_marg || screen->cur_row + amount <= screen->bot_marg) { CursorDown(screen, amount); return; } CursorDown(screen, j = screen->bot_marg - screen->cur_row); #ifdef vax11c XtermDoScroll(screen, amount - j); #else Scroll(screen, amount - j); #endif /* vax11c */ } /* * Moves cursor up amount lines, reverse scrolls if necessary. * Won't leave scrolling region. No carriage return. */ RevIndex(screen, amount) register TScreen *screen; register int amount; { /* * reverse indexing when above scrolling region is cursor up. * if cursor low enough, no reverse indexing needed */ if (screen->cur_row < screen->top_marg || screen->cur_row-amount >= screen->top_marg) { CursorUp(screen, amount); return; } RevScroll(screen, amount - (screen->cur_row - screen->top_marg)); CursorUp(screen, screen->cur_row - screen->top_marg); } /* * Moves Cursor To First Column In Line */ CarriageReturn(screen) register TScreen *screen; { screen-s`V. XTERM021.BCKer`[MAHAN.XTERM]CURSOR.C;6Y9 >cur_col = 0; screen->do_wrap = 0; _CheckSelection(screen); } /* * Save Cursor and Attributes */ CursorSave(term, sc) register XtermWidget term; register SavedCursor *sc; { register TScreen *screen = &term->screen; sc->row = screen->cur_row; sc->col = screen->cur_col; sc->flags = term->flags; sc->curgl = screen->curgl; sc->curgr = screen->curgr; bcopy(screen->gsets, sc->gsets, sizeof(screen->gsets)); } /* * Restore Cursor and Attributes */ CursorRestore(term, sc) register XtermWidget term; register SavedCursor *sc; { register TScreen *screen = &term->screen; bcopy(sc->gsets, screen->gsets, sizeof(screen->gsets)); screen->curgl = sc->curgl; screen->curgr = sc->curgr; term->flags &= ~(BOLD|INVERSE|UNDERLINE|ORIGIN); term->flags |= sc->flags & (BOLD|INVERSE|UNDERLINE|ORIGIN); CursorSet (screen, (term->flags & ORIGIN) ? sc->row - screen->top_marg : sc->row, sc->col, term->flags); } *[MAHAN.XTERM]DATA.C;2+,fr. /@ 4P -`0123KPWO56%ق+78 +8\JQ9G@HJtUǜ XTERM021.BCKfr`[MAHAN.XTERM]DATA.C;2P 8/* * $XConsortium: data.c,v 1.8 89/05/26 18:10:43 jim Exp $ */ #ifdef vax11c #include #else #include #endif /* vax11c */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * 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, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ #include #ifdef vax11c #include #include #else #include #include #endif /* vax11c */ #include "ptyx.h" #include "data.h" #ifndef lint static char rcs_id[] = "$XConsortium: data.c,v 1.8 8uڜ XTERM021.BCKfr`[MAHAN.XTERM]DATA.C;2P n9/05/26 18:10:43 jim Exp $"; #endif /* lint */ XPoint T_boxlarge[NBOX] = { {0, 0}, {8, 0}, {0, 14}, {-8, 0}, {0, -14}, }; XPoint T_box2[NBOX] = { {0, 0}, {7, 0}, {0, 12}, {-7, 0}, {0, -12}, }; XPoint T_box3[NBOX] = { {0, 0}, {5, 0}, {0, 12}, {-5, 0}, {0, -12}, }; XPoint T_boxsmall[NBOX] = { {0, 0}, {5, 0}, {0, 9}, {-5, 0}, {0, -9}, }; jmp_buf Tekend; int Tbcnt = 0; Char *Tbuffer; Char *Tbptr; TekLink *TekRefresh; Char *Tpushb; Char *Tpushback; int Ttoggled = 0; int bcnt = 0; Char buffer[BUF_SIZE]; Char *bptr = buffer; jmp_buf VTend; XPoint VTbox[NBOX] = { {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, }; #ifdef DEBUG int debug = 0; /* true causes error messages to be displayed */ #endif /* DEBUG */ XtermWidget term; /* master data structure for client */ char *xterm_name; /* argv[0] */ int am_slave = 0; /* set to 1 if running as a slave process */ int max_plus1; int pty_mask; int Select_mask; int X_mask; char *ptydev; char *ttydev; char log_def_name[] = "XtermLog.XXXXX"; int T_lastx = -1; int T_lasty = -1; int waitingForTrackInfo = 0; EventMode eventMode = NORMAL; GC visualBellGC; int VTgcFontMask = GCFont; int TEKgcFontMask = GCFont; TekWidget tekWidget; vߍ2 XTERM021.BCKs`[MAHAN.XTERM]DATA.H;3K'*[MAHAN.XTERM]DATA.H;3+,s./@ 4KQ-`0123KPWO56)H R7GKH R8G١9G@HJ/* * $XConsortium: data.h,v 1.7 89/05/26 18:10:45 jim Exp $ */ #ifdef vax11c #include #else #include #endif /* vax11c */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * 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, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORw] XTERM021.BCKs`[MAHAN.XTERM]DATA.H;3KV * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* @(#)data.h\tX10/6.6\t11/10/86 */ #ifdef vax11c #include #else #include #endif /* vax11c */ extern TekLink *TekRefresh; extern XPoint T_box2[]; extern XPoint T_box3[]; extern XPoint T_boxlarge[]; extern XPoint T_boxsmall[]; extern XPoint VTbox[]; extern Char *Tbptr; extern Char *Tbuffer; extern Char *Tpushb; extern Char *Tpushback; extern Char *bptr; extern char log_def_name[]; extern char *ptydev; extern char *ttydev; extern char *xterm_name; extern Char buffer[]; extern int Select_mask; extern int T_lastx; extern int T_lasty; extern int Tbcnt; extern int Ttoggled; extern int X_mask; extern int am_slave; extern int bcnt; #ifdef DEBUG extern int debug; #endif /* DEBUG */ #ifdef vax11c extern volatile int noshare errno; #else extern int errno; #endif /* vax11c */ extern int max_plus1; extern int pty_mask; extern int switchfb[]; extern jmp_buf Tekend; extern jmp_buf VTend; extern int waitingForTrackInfo; extern EventMode eventMode; extern GC visualBellGC; extern int VTgcFontMask; extern int TEKgcFontMask; extern XtermWidget term; extern TekWidget tekWidget; xS+ XTERM021.BCKhr`[MAHAN.XTERM]DECKEYSYM.H;18y*[MAHAN.XTERM]DECKEYSYM.H;1+,hr./@ 48`mF-`0123KPWO56`mF7ʮmF8pQ9G@HJ/* $XConsortium: DECkeysym.h,v 1.2 88/09/06 15:55:54 jim Exp $ */ /*********************************************************** Copyright 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved 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, and that the names of Digital or MIT not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVy  }vH;1Y ! 9='I =3'2GGXS?4U@co0/j.*LTm)t=]*H9K `L.&[SL=n8@EqP shq?ux27Ta\1B8Q,^8KO\&]frn pn$m{0~h]*F8unC,20v~^b51Key x^M Oo?Q5k4fPĭ*}2ņB"ecͯ7f0u6HyCfbv}%q-gz3%rJ @*4?%8R9Ubt5S&)v<{O8JIyi F +/6]G2#e(z'K)bpe# a2D`fyFWyS^m,~A 1.u@@au3BY = U(ED/((dt BSJ= ?|6*B4PS&70lH0ZLOOqtIWom() SV;4]r8JEq<6TA,%'-c!&AO^RB< jpGT GRU g \;_C9 bX` G 5aU`S>(7%e,/r!qo vt2V%CwP/)aAE5E"'{('eN~tyuQ{)f29\::$.3dT|YU&bSeV;8L:rccqJ|3%# EiOd S+?A[[m["Vvgp$g*Mwc+|M2=+\oJU,[@l=V.hOzKaAxpL6Tyz H1REo_e #W x+*z:N<|UB5BKpcJ|B &'^PL;,~StL1z`:9RZZ-0~>'Zri(Az<Z I2*|T _r`Odk">>p@ !4$6)8i6Dupc,n:g m5K ?\%5#zH" #1iM(Hy/eaF.9JQ8wwQe5"+>*7&J$O. p>/J\Y cn 5j%;!D tzl,7T"3w?aeMim+M(f(X W [.o^)mlG.kF |wh 3zFs C\2`l k4$P&q1$\m9#9i/r)ITowvvFh5x ..Xjuyl$>_ T*p mb,c~xm.ec%5yW5nTfriTM&Pi3/{4 1nA/DFsm3;VH^S\]E.h,f/:n^mx"2DWGiB`u_S" 8$W,[_' }a>; #;jtIsw]./) b)I]9!`AQ@ZGr< Is~) LU hWFAIYyr QJnB NDZ Ve]Da_;-6yz;+u XTERM021.BCKhr`[MAHAN.XTERM]DECKEYSYM.H;1 ER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ #define DXK_Remove 0x1000FF00 /* Remove */ &*[MAHAN.XTERM]DECW$DISPLAY-HACK.BLURB;1+,ir./@ 4]-`0123KPWO56ʐ-ȓ7G80*Q9G@HJ]From: IN%"BRAND@addvax.llnl.gov" "Hal R. Brand, LLnL (415)-422-6312" 5-SEP-1990 16:06:40.88To: leonard@Arizona.EDUCC: @Subj: XTERM for VMS DECWindows - a fix to propogate DECW$DISPLAYFReceived: from addvax.llnl.gov by Arizona.edu; Wed, 5 Sep 90 16:06 MSTDate: Wed, 5 Sep 90 16:05 PDTAFrom: "Hal R. Brand, LLnL (415)-422-6312" CSubject: XTERM for VMS DECWindows - a fix to propogate DECW$DISPLAYTo: leonard@Arizona.EDU0Message-id: <3BAE98CDDEFF003B51@addvax.llnl.go{S' XTERM021.BCKir`&[MAHAN.XTERM]DECW$DISPLAY-HACK.BLURB;1].Av>X-Envelope-to: leonard"X-VMS-To: IN%"leonard@arizona.edu"IIncase you care, below is a new (slightly modified) version of VMS.C thatDpropogates the DECW$DISPLAY logical. Thanks for making XTERM for VMS available! Hal Brand LLnL*[MAHAN.XTERM]DIFF.COM;3+,jr. /@ 4t X-`0123KPWO 56̟[67HL[68 R9G@HJ$ v = 'f$verify(0)$!$! Header files$!k$ DIFF/OUTPUT=data.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]data.h -H altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]data.hm$ DIFF/OUTPUT=error.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]error.h -I altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]error.hk$ DIFF/OUTPUT=main.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012|n XTERM021.BCKjr`[MAHAN.XTERM]DIFF.COM;3t ^.xterm]main.h -H altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]main.hk$ DIFF/OUTPUT=menu.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]menu.h -H altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]menu.hk$ DIFF/OUTPUT=ptyx.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]ptyx.h -H altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]ptyx.hr$ DIFF/OUTPUT=texparse.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]tekparse.h -L altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]tekparse.hq$ DIFF/OUTPUT=vtparse.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]vtparse.h -K altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]vtparse.h$! $! C sources$!o$ DIFF/OUTPUT=button.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]button.c -J altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]button.cr$ DIFF/OUTPUT=charproc.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]charproc.c -L altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]charproc.co$ DIFF/OUTPUT=cursor.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]cursor.c -J altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]cursor.cm$ DIFF/OUTPUT=data_c.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm0}Du XTERM021.BCKjr`[MAHAN.XTERM]DIFF.COM;3t @12.xterm]data.c -H altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]data.cm$ DIFF/OUTPUT=input.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]input.c -I altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]input.cm$ DIFF/OUTPUT=main_c.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]main.c -H altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]main.cm$ DIFF/OUTPUT=menu_c.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]menu.c -H altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]menu.ck$ DIFF/OUTPUT=misc.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]misc.c -H altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]misc.co$ DIFF/OUTPUT=resize.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]resize.c -J altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]resize.co$ DIFF/OUTPUT=screen.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]screen.c -J altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]screen.ct$ DIFF/OUTPUT=scrollbar.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]scrollbar.c -M altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]scrollbar.ck$ DIFF/OUTPUT=tabs.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]tabs.c -H altus~Wp>L XTERM021.BCKjr`[MAHAN.XTERM]DIFF.COM;3t -ers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]tabs.cq$ DIFF/OUTPUT=tekproc.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]tekproc.c -K altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]tekproc.ct$ DIFF/OUTPUT=tekprstbl.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]tekprstbl.c -M altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]tekprstbl.ck$ DIFF/OUTPUT=util.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]util.c -H altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]util.cr$ DIFF/OUTPUT=vtprstbl.dif/ignore=blank altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm012.xterm]vtprstbl.c -L altusers:[mahan.xdemos_x11r4.clients.new_xterm.xterm20.xterm]vtprstbl.c$ if v then set verify*[MAHAN.XTERM]ERROR.H;2+,kr. /@ 4O y-`0123KPWO 56T@)7@)8!FR9G@HJ O4 XTERM021.BCKkr`[MAHAN.XTERM]ERROR.H;2O p/* * $XConsortium: error.h,v 1.6 89/05/26 13:34:16 jim Exp $ */ #ifdef vax11c #include #else #include #endif /* vax11c */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * 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, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* @(#)error.h X10/6.6 11/6/86 */ /* main.c */ #define ERROR_KMALLOC 10 /* main: malloc() failed for keyboardtype */ #define ERROR_FIONBIO 11 /* main: ioctl() failed on FIONBIO */ #define ERROR_OPDEVTTY 14 /* spawn: open() failed on /dev/tty */ #define ERROR_TIOCGETP 15 /* s^: XTERM021.BCKkr`[MAHAN.XTERM]ERROR.H;2O Opawn: ioctl() failed on TIOCGETP */ #define ERROR_TIOCGETC 16 /* spawn: ioctl() failed on TIOCGETC */ #define ERROR_TIOCGETD 17 /* spawn: ioctl() failed on TIOCGETD */ #define ERROR_TIOCGLTC 18 /* spawn: ioctl() failed on TIOCGLTC */ #define ERROR_TIOCLGET 19 /* spawn: ioctl() failed on TIOCLGET */ #define ERROR_TIOCCONS 20 /* spawn: ioctl() failed on TIOCCONS */ #define ERROR_OPDEVTTY2 21 /* spawn: second open() failed on /dev/tty */ #define ERROR_NOTTY 22 /* spawn: ioctl() failed on TIOCNOTTY */ #define ERROR_TIOCSETP 23 /* spawn: ioctl() failed on TIOCSETP */ #define ERROR_TIOCSETC 24 /* spawn: ioctl() failed on TIOCSETC */ #define ERROR_TIOCSETD 25 /* spawn: ioctl() failed on TIOCSETD */ #define ERROR_TIOCSLTC 26 /* spawn: ioctl() failed on TIOCSLTC */ #define ERROR_TIOCLSET 27 /* spawn: ioctl() failed on TIOCLSET */ #define ERROR_FORK 29 /* spawn: fork() failed */ #define ERROR_EXEC 30 /* spawn: exec() failed */ #define ERROR_OPDEVTTY3 31 /* spawn: third open() failed on /dev/tty */ #define ERROR_PTYS 32 /* get_pty: not enough ptys */ #define ERROR_NOX 33 /* get_terminal: can't connect to server */ #define ERROR_PTY_EXEC 34 /* waiting for initial map */ #define ERROR_INIT 36 /* spawn: can't initialize window */ #define ERROR_NOCO 37 /* resize: no `co' in termcap */ #define ERROR_NOLI 38 /* resize: no `li' in termcap */ #define ERROR_BORDER 39 /* get_terminal: can't make border tile */ #define ERROR_BACK 40 /* get_terminal: can't make background tile */ #define ERROR_NOX3 43 /* get_terminal: bad1 XTERM021.BCKkr`[MAHAN.XTERM]ERROR.H;2O ] pty from display server */ /* charproc.c */ #define ERROR_SELECT 50 /* in_put: select() failed */ #define ERROR_VINIT 54 /* VTInit: can't initialize window */ #define ERROR_CNMALLOC1 55 /* Changename: malloc failed */ #define ERROR_CNMALLOC2 56 /* Changename: malloc failed */ /* Tekproc.c */ #define ERROR_TSELECT 60 /* Tinput: select() failed */ #define ERROR_TINIT 64 /* TekInit: can't initialize window */ #define ERROR_TBACK 65 /* TekBackground: can't make background */ /* button.c */ #define ERROR_BMALLOC2 71 /* SaltTextAway: malloc() failed */ /* misc.c */ #define ERROR_LOGEXEC 80 /* StartLog: exec() failed */ #define ERROR_XERROR 83 /* xerror: XError event */ #define ERROR_XIOERROR 84 /* xioerror: X I/O error */ #define ERROR_WINNAME 85 /* get_terminal: malloc failed */ /* screen.c */ #define ERROR_SCALLOC 90 /* Alloc: calloc() failed on base */ #define ERROR_SCALLOC2 91 /* Alloc: calloc() failed on rows */ #define ERROR_SREALLOC 92 /* ScreenResize: realloc() failed on alt base */ #define ERROR_SREALLOC2 93 /* ScreenResize: realloc() failed on alt rows */ #define ERROR_SREALLOC3 94 /* ScreenResize: realloc() failed on rows */ #define ERROR_SREALLOC4 95 /* ScreenResize: realloc() failed on rows */ #define ERROR_RESIZE 96 /* ScreenResize: malloc() or realloc() failed */ #define ERROR_RESIZE2 97 /* ScreenResize: malloc() or realloc() failed */ #define ERROR_RESIZROW 98 /* ScreenResize: realloc() failed on alt char */ #define ERROR_RESIZROW2 99 /* ScreenResize: realloc() failed on alt attr */ #define EDW۪ XTERM021.BCKkr`[MAHAN.XTERM]ERROR.H;2O v RROR_RESIZROW3 100 /* ScreenResize: realloc() failed on attr */ #define ERROR_RESIZROW4 101 /* ScreenResize: realloc() failed on attr */ /* scrollbar.c */ #define ERROR_SBRALLOC 110 /* ScrollBarOn: realloc() failed on base */ #define ERROR_SBRALLOC2 111 /* ScrollBarOn: realloc() failed on rows */ /* util.c */ #define ERROR_UBACK 120 /* ReverseVideo: can't make background */ -*[MAHAN.XTERM]ESC-CODES-TO-SWITCH-MODES.HINT;1+,lr./@ 4P-`0123KPWO56Д7ֱwG8ToR9G@HJE <<< UAZHEP::USR$ROOT1:[NOTES$LIBRARY]DECWINDOWS.NOTE;1 >>>6 -< DECwindows information >-P================================================================================PNote 18.5 A Tektronix 4014 window for DECwindows 5 of 6P51383::VRH 10 lines 29-OCT-1990 14:40< -< Here they are in all their glory! >-P--------------------------------------------------------------------------mU XTERM021.BCKlr`-[MAHAN.XTERM]ESC-CODES-TO-SWITCH-MODES.HINT;1P------L Well, I went and did it. I looked through the Xterm C code (yech!, whatA a mess!) and found Xterm's window switching escape sequences. O VT102 window to Tek: "[?38h" (Xterm's "DECTEK" - a DEC-like set mode)- in decimal: /27,91,63,51,56,104/ % Tek window to VT102: "" in decimal: /27,3/ C I've written a small test program and verified that these work.*[MAHAN.XTERM]IMAKEFILE.;1+,mr. /@ 4 -`0123KPWO56Bgڔ7+λ(80R9G@HJ/**/########################################################################### /**/# # /**/# Attention xterm porters # /**/# # /**/# # /**/# Xterm assumes that bcopy can handle overlapping arguments. If your # /**/# bcopy (or memcpy) can't, w(w u|]-1 m a~b.HINT;1y-]It=+hA[WBft^:Lp,sX!~XQh&8pph/E|_xgly hHd *>]nU{ n} B|C&*&]cwE06xbXi<d^)Xb ymtZ*.LrF*Z HNB5exm2f0dzwfAr(};+l@a 5[V7KQK r \gi$I {(wg\h`|5. |?`2A%8x`y F,yC?0<p #*xExjwq;nRgIEyLLfoKW27Ow[uPy`H]6dqHQO+vs_!W_1Q7$$SQU,6e8 %A+MS!FpW~Ken3r2ApwHWkyuKqJI)@SzlC 5N9HU|[@6`|I }4t(7hK]Uw7B;a[=N`p&6j$D5b,f8 -`oVc VxjaUQGJ|_P\S]R X\`=>UOUU v<`|bb`FPK~ KuHQ{2J`pqJxp#`O*s F_ @Sp1#{h;YF _T ZhwN^l\lY?>57*:`8$J] |%m=e"7>J_Q){]!K= .7 NEJ4 *7,{oH(L.Qd{6\\ZI*wCp: }FgJaHa9SP;-lniY0(1 .V^J> PKAa!jbJh*#=a+L06nyuo]qh[TTK-zF.iyEJ9#V 9ME*&"X#C&~0l < >IQ&_),v#(TwH r>::k?1#.6aO RV JHzA4*%)FmO."gc)TcaNpj{`zvotu;.{ap ( :ga3J(p'f~V8wi- \ZJp%8i $~wj R!W{@PH?2+;pH m,}rM"ffqH9 l1#+.":m%;FqRYH 8H8l_agNOh+P XTERM021.BCKmr`[MAHAN.XTERM]IMAKEFILE.;1 }rite a routine called bcopy and link it in # /**/# or add -Dbcopy=mybcopy to the DEFINES list below. # /**/# # /**/########################################################################### #ifdef BandAidCompiler #include BandAidCompiler #endif /* * add -DWTMP and -DLASTLOG if you want them; make sure that bcopy can * handle overlapping copies before using it. */ #ifdef SetTtyGroup /* turn on in config/machine.cf */ TTYGROUPDEF = -DUSE_TTY_GROUP #endif /* * [PUCC = Purdue University Computer Center] * If you use PUCC's ptyd, add "-DPUCC_PTYD" to the DEFINES * and dink the -DUTMP (also don't define WTMP or LASTLOG - since * ptyd does all that logging for you) You will need to add * the right library load line (we use -lpucc) to the * ComplexProgramTarget (right next to -ltermcap) */ #ifdef UsePUCCPtyd /* turn on in config/site.def */ PUCCPTYDDEF = -DPUCC_PTYD /* does not need to be setuid */ PTYLIB = -lpucc #endif MAIN_DEFINES = -DUTMP $(TTYGROUPDEF) $(PUCCPTYDDEF) SRCS1 = button.c charproc.c cursor.c data.c input.c \ main.c menu.c misc.c screen.c scrollbar.c tabs.c \ TekPrsTbl.c Tekproc.c util.c VTPrsTbl.c OBJS1 = main.o input.o charproc.o cursor.o util.o tabs.o \ screen.o scrollbar.o button.o Tekproc.o misc.o \ VTPrsTbl.o TekPrsTbl.o data.o menu.o SRCS2 = resize.c OBJS2 = resize.o SRCS = $(SRCS1) $(SRCS2) }1e+ XTERM021.BCKmr`[MAHAN.XTERM]IMAKEFILE.;1  OBJS = $(OBJS1) $(OBJS2) PROGRAMS = resize xterm DEPLIBS1 = XawClientDepLibs DEPLIBS2 = PROGRAMS = xterm resize #ifdef CrayArchitecture TERMCAPLIB = -lcurses #else TERMCAPLIB = -ltermcap #endif AllTarget($(PROGRAMS)) SpecialObjectRule(main.o, ,$(MAIN_DEFINES)) NormalProgramTarget(xterm,$(OBJS1),$(DEPLIBS1),XawClientLibs,$(TERMCAPLIB) $(PTYLIB)) InstallProgramWithFlags(xterm, $(BINDIR), $(INSTUIDFLAGS)) NormalProgramTarget(resize,$(OBJS2),$(DEPLIBS2), ,$(TERMCAPLIB)) InstallProgramWithFlags(resize, $(BINDIR), ) InstallAppDefaults(XTerm) InstallManPage(xterm,$(MANDIR)) InstallManPage(resize,$(MANDIR)) DependTarget() *[MAHAN.XTERM]INPUT.C;3+,nr./@ 4\l-`0123KPWO56ХD7P*D8sR9G@HJ3- XTERM021.BCKnr`[MAHAN.XTERM]INPUT.C;3\/* * $XConsortium: input.c,v 1.8 89/12/10 20:44:48 jim Exp $ */ #ifndef lint static char *rcsid_input_c = "$XConsortium: input.c,v 1.8 89/12/10 20:44:48 jim Exp $"; #endif /* lint */ #ifdef vax11c #include #else #include #endif /* vax11c */ /* * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * * All Rights Reserved * * 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, and that the name of Digital Equipment * Corporation not be used in advertising or publicity pertaining to * distribution of the software without specific, written prior permission. * * * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * SOFTWARE. */ /* input.c */ #ifndef lint static char rcs_id[] = "$XConsortium: input.c,v 1.8 89/12/10 20:44:48 jim Exp $"; #endif /* lint */ #ifdef vax11c #include #include #include #include #include #else #include #include #include #include #include #endif /* vax11c */ #include #include "ptyx.h" static XComposeStatus compose_status = {NULL, 0}; static char *kypd_num = " XXXXXXXX\tXXX\rXXXxxxxXXXXXXXXXXXXXXXXXXXXX*+,-.\\0123456789XXX="; static char *kypd_apl = " ABCDEFGHIJKLMNOPQRSTUVWXYZ??????abcdefghijklmnopqrstuvwxyzXXX"; static char *cur = "DACB"; static int funcvalue(), sunfuncvalue(); extern Boolean sunFunctionKeys; void AdjustAfterInput (screen) register TScreen *screen; { if(screen->scrollkey && screen->topline != 0) WindowScroll(screen, 0); if(screen->marginbell) { int col = screen->max_col - screen->nmarginbell; if(screen->bellarmed >= 0) { if(screen->bellarmed == screen->cur_row) { if(screen->cur_col >= col) { if(screen->cur_col == col) Bell(); screen->bellarmed = -1; } } else screen->bellarmed = screen->cur_col < col ? screen->cur_row : -1; } else if(screen->cur_col < col) screen->bellarmed = screen->cur_row; } } Input (keyboard, screen, event, eightbit) register TKeyboard *keyboard; register TScreen *screen; register XKeyPressedEvent *event; Bool eightbit; { #define STRBUFSIZE 100 char strbuf[STRBUFSIZE]; register char *string; register int key = FALSE; int pty = screen->respond; int nbytes; KeySy2N XTERM021.BCKnr`[MAHAN.XTERM]INPUT.C;3\:m keysym; ANSI reply; nbytes = XLookupString ((XKeyEvent *)event, strbuf, STRBUFSIZE, &keysym, &compose_status); string = &strbuf[0]; reply.a_pintro = 0; reply.a_final = 0; reply.a_nparam = 0; reply.a_inters = 0; if (IsPFKey(keysym)) { reply.a_type = SS3; unparseseq(&reply, pty); unparseputc((char)(keysym-XK_KP_F1+'P'), pty); key = TRUE; } else if (IsKeypadKey(keysym)) { if (keyboard->flags & KYPD_APL) { reply.a_type = SS3; unparseseq(&reply, pty); unparseputc(kypd_apl[keysym-XK_KP_Space], pty); } else unparseputc(kypd_num[keysym-XK_KP_Space], pty); key = TRUE; } else if (IsCursorKey(keysym) && keysym != XK_Prior && keysym != XK_Next) { if (keyboard->flags & CURSOR_APL) { reply.a_type = SS3; unparseseq(&reply, pty); unparseputc(cur[keysym-XK_Left], pty); } else { reply.a_type = CSI; reply.a_final = cur[keysym-XK_Left]; unparseseq(&reply, pty); } key = TRUE; } else if (IsFunctionKey(keysym) || IsMiscFunctionKey(keysym) || keysym == XK_Prior || keysym == XK_Next || keysym == DXK_Remove) { reply.a_type = CSI; reply.a_nparam = 1; if (sunFunctionKeys) { reply.a_param[0] = sunfuncvalue (keysym); reply.a_final = 'z'; } else { reply.a_param[0] = funcvalue (keysym); reply.a_final = '~'; } if (reply.a_param[0] > 0) unparseseq(&reply, pty); key = TRUE; } else if (nbytes > 0) { if(screen->TekGIN) { TekEnqMouse(*string++); TekGINoff(); nbytes--; } if ((nbytes == 1)  QG XTERM021.BCKnr`[MAHAN.XTERM]INPUT.C;3\g && eightbit) { if (screen->eight_bits) *string |= 0x80; /* turn on eighth bit */ else unparseputc (033, pty); /* escape */ } while (nbytes-- > 0) unparseputc(*string++, pty); key = TRUE; } if(key && !screen->TekEmu) AdjustAfterInput(screen); #ifdef ENABLE_PRINT if (keysym == XK_F2) TekPrint(); #endif return; } StringInput (screen, string) register TScreen *screen; register char *string; { int pty = screen->respond; int nbytes; nbytes = strlen(string); if(nbytes && screen->TekGIN) { TekEnqMouse(*string++); TekGINoff(); nbytes--; } while (nbytes-- > 0) unparseputc(*string++, pty); if(!screen->TekEmu) AdjustAfterInput(screen); } static int funcvalue (keycode) int keycode; { switch (keycode) { case XK_F1: return(11); case XK_F2: return(12); case XK_F3: return(13); case XK_F4: return(14); case XK_F5: return(15); case XK_F6: return(17); case XK_F7: return(18); case XK_F8: return(19); case XK_F9: return(20); case XK_F10: return(21); case XK_F11: return(23); case XK_F12: return(24); case XK_F13: return(25); case XK_F14: return(26); case XK_F15: return(28); case XK_Help: return(28); case XK_F16: return(29); case XK_Menu: return(29); case XK_F17: return(31); case XK_F18: return(32); case XK_F19: return(33); case XK_F20: return(34); case XK_Find : return(1); case XK_Insert: return(2); case XK_Delete: return(3); case DXK_Remove: return(3); case XK_Select: return(4); case XK_Prior: return( XTERM021.BCKnr`[MAHAN.XTERM]INPUT.C;3\ 5); case XK_Next: return(6); default: return(-1); } } static int sunfuncvalue (keycode) int keycode; { switch (keycode) { case XK_F1: return(224); case XK_F2: return(225); case XK_F3: return(226); case XK_F4: return(227); case XK_F5: return(228); case XK_F6: return(229); case XK_F7: return(230); case XK_F8: return(231); case XK_F9: return(232); case XK_F10: return(233); case XK_F11: return(192); case XK_F12: return(193); case XK_F13: return(194); case XK_F14: return(195); case XK_F15: return(196); case XK_Help: return(196); case XK_F16: return(197); case XK_Menu: return(197); case XK_F17: return(198); case XK_F18: return(199); case XK_F19: return(200); case XK_F20: return(201); case XK_R1: return(208); case XK_R2: return(209); case XK_R3: return(210); case XK_R4: return(211); case XK_R5: return(212); case XK_R6: return(213); case XK_R7: return(214); case XK_R8: return(215); case XK_R9: return(216); case XK_R10: return(217); case XK_R11: return(218); case XK_R12: return(219); case XK_R13: return(220); case XK_R14: return(221); case XK_R15: return(222); case XK_Find : return(1); case XK_Insert: return(2); case XK_Delete: return(3); case DXK_Remove: return(3); case XK_Select: return(4); case XK_Prior: return(5); case XK_Next: return(6); default: return(-1); } } ` XTERM021.BCKor`[MAHAN.XTERM]LIB.DIR;1*[MAHAN.XTERM]LIB.DIR;1+,or./@ 4-`0123 KPWO56R7P-R8P-S9G@HJIMAKE.COMprMISC.DIRqrX11.DIRwrXAW.DIRzrXMU.DIRr *[MAHAN.XTERM.LIB]MAKE.COM;2+,pr./@ 4W-or0123KPWO56B$LP7tRLP80LS9G@HJ$ SAVE_VERIFY='F$VERIFY(0)%$ if p1 .Eqs. "CLEAN" then goto clean)$ if p1 .Eqs. "CLOBBER" then goto clobber)$ if p1 .Eqs. "INSTALL" then goto install$!$$! Compile the X11R4 Xterm libraries$!$ Set Symbol/Scope=NoGlobal$!$! build the athena widget set$!$ set default [.xaw] $ @make 'p1'$ set default [-]$!$! build the Xmu library$!$ set default [.xmu] $ @make 'p1'$ set default [-]$!($! build the X VMS miscellaneous library$!$ set default [.misc] $ @make 'p1'$ sepq XTERM021.BCKprorAHAN.XTERM.LIB]MAKE.COM;2Wt default [-]$!$ exit$!W$ Clobber: ! Delete executables, Purge directory and clean up object files and listings$ Delete/noconfirm/log *.exe;*$!>$ Clean: ! Purge directory, clean up object files and listings$ Purge$ Delete/noconfirm/log *.lis;*$ Delete/noconfirm/log *.obj;*$!$ exit$! $ Install:$ Copy/log *.exe x11bin:$ exit$!5$MAKE: SUBROUTINE !SUBROUTINE TO CHECK DEPENDENCIES$ V = 'F$Verify(0)"$! P1 = What we are trying to make$! P2 = Command to make it$! P3 - P8 What it depends on$+$ If F$Search(P1) .Eqs. "" Then Goto Makeit#$ Time = F$CvTime(F$File(P1,"RDT"))$arg=3$Loop:$ Argument = P'arg%$ If Argument .Eqs. "" Then Goto Exit$ El=0$Loop2:#$ File = F$Element(El," ",Argument)"$ If File .Eqs. " " Then Goto Endl $ AFile = ""$Loop3:$ OFile = AFile$ AFile = F$Search(File);$ If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl>$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit $ Goto Loop3$NextEL: $ El = El + 1 $ Goto Loop2$EndL: $ arg=arg+1$ If arg .Le. 8 Then Goto Loop $ Goto Exit$$Makeit: $ Set Verify$ 'P2$ VV='F$Verify(0)$Exit:$ If V Then Set Verify$ENDSUBROUTINELc6 XTERM021.BCKqrorAHAN.XTERM.LIB]MISC.DIR;15*[MAHAN.XTERM.LIB]MISC.DIR;1+,qr./@ 4-or0123 KPWO56^R7[+R8[zS9G@HJI GETHOSTNAME.Crr MAKE.COM(sr  STRINGS.MARur%*[MAHAN.XTERM.LIB.MISC]GETHOSTNAME.C;1+,rr ./@ 4I.0XGF-qr0123KPWO560XGF7HGF80=S9G@HJ/*3 * gethostname(2) - VMS Version of the UNIX routine *4 * This routine simply translates the system logical6 * name SYS$NODE and returns the result. This does not3 * exactly match UNIX behaviour. In particular, the5 * double colon at the end of the node name may cause * problems in ported code. */#include #include #include #include #define NULL 0L9int gethostname(name, namelen) /*--- Get node name ---*/ char name[]; int nam7'{o  0$Sbg%KMoD9u4n 5jjw8'Fq|c76oMF48eKEy#&F.~] a TV^mZ/P `Qu POoyfKyP7)Bp ~y B3vw[ ,(:VUXgiE_1_6uA\77"s#BQ bB:($Lw(79iN7#K#E<{==YxJXd>^:)S>Z[,_gK+!,W |$T*J<Er ?\5pa ,y1|`(t4 72UFh&wn< $:K'!ZJAsmv!t}uq&fyLn7D/ /A0@*(SUnVJE`cFw4U\sOc D^q:%!tbͳ]wnj:ErT=qpHIk]#am?SAbhRZ[fE9~8.kOd)LDO$|MXET1d9)" A, Rx.CiYcAN4?qHUELKum1CIh Tj ~?IK\i:qcE !Vc $InyQaY_it"R0QF2bG$WNf[tZ5 Yz[`6Y]vv#H6oK~F<h eynqOHTt@mSviBFhKn h!PICVFT$/! /pUl jou~+NX~FyJ]qȱQ;z!/My_>.`E+~.5/lP*,3|)wH-`Res z9EKVs_$]ki M=aFN+~BZ.Lw@rz ]1TE >5PJla#@G.yJ!~JKJ+pBwxf(xy,LAn7BBs})c Pp7'*h|st\q)7sO^QQCZ4cX?;jt?J7 G8:| .'"]nDkK\1In7$kwLZtZ,U7h('EtA{c$ If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit $ Goto Loop3$NextEL: $ El = El + 1 $ Goto Loop2$EndL: $ arg=arg+1$ If arg .Le. 8 Then Goto Loop $ Goto Exit$$Makeit: $ Set Verify$ 'P2$ VV='F$Verify(0)$Exit:$ If V Then Set Verify$ENDSUBROUTINEi XTERM021.BCKurqr#[MAHAN.XTERM.LIB.MISC]STRINGS.MAR;1K z<#*[MAHAN.XTERM.LIB.MISC]STRINGS.MAR;1+,ur. /@ 4K 2/F-qr0123KPWO56/F7FF8pCT9G@HJ .ident "1.0-002", .title String routines for Ultrix emulation% .psect strings,exe,rel,shr,pic,nowrt;; bcopy(src, dest, length);'; char *src; /* source string *//; char *dest; /* dest string */2; unsigned long int length; /* length in bytes */;K; This routine copies the specified number of bytes from the source stringF; to the destination string. If the specified length is longer thatn 8; 64kb, then it copies 64kb each time until it is done.; ".entry bcopy,^M movl #65535,r7 ; counter ! movl 12(ap),r6 ; amount to copy next_block: cmpl r6,r7 ; are we done yet? bgtru do_copy, movl r6,r7 ; only need to move what's leftdo_copy: movc3 r7,@4(ap),@8(ap); move it0 subl2 r7,r6 ; adjust counter to the next block bleq copy_done movl r1,4(ap) movl r3,8(ap) brw next_block ; do it again copy_done: ret ;++;; bcmp( source, dest, len ); char *source, *dest; ; int len;;C; copies (len) bytes f\5Z XTERM021.BCKurqr#[MAHAN.XTERM.LIB.MISC]STRINGS.MAR;1K 0rom (source) to (dest) regardless of contents;;--.entry bcmp,^m2 cmpc3 12(ap),@4(ap),@8(ap) ; that's all, folks... beql 10$ movl #-1,R0 ;fail ret10$: movl #0,R0 ;SUCCESS ret ;++;; bzero( dest, len ) ; char *dest; ; int len;;#; writes (len) zero bytes into dest;;--.entry bzero,^m5 movc5 #0,@4(ap),#0,8(ap),@4(ap) ; will pad with nuls ret ;++;; int ffs( i ); int i;;?; finds the first bit set in the argument and returns the index; of that bit (starting at 1).;;-- .entry ffs,0 ffs #0,#32,4(ap),r0 beql 10$ ; branch if arg=0$ incl r0 ; VAX counts bits from 0 ret+10$: movl #-1,r0 ; no set bits, return -1 ret ;++;; char *index( string, c ); char *string, c;;B; returns pointer to first occurrence of character c within string; or zero if not found.;;--.entry index,0/ locc #0,#-1,@4(ap) ; find end of string first+ subl 4(ap),r1 ; compute length of string& locc 8(ap),r1,@4(ap) ; now find char bneq 10$( clrl r1 ; clear pointer if not found&10$: movl r1,r0 ; return the pointer ret ;++;; char *rindex( string, c ); char *string, c;;A; returns pointer to last occurrence of character c within string; or zero if not found.;;--.entry rindex,^M/ locc #0,#-1,@4(ap) ; find end of string first. subl3 4(ap),r1,r0 ; compute length of string" clrl r2 ; assume no occurrence# movl 4(ap),r1 ; starting adq^6 XTERM021.BCKurqr#[MAHAN.XTERM.LIB.MISC]STRINGS.MAR;1K 1dress+10$: locc 8(ap),r0,(r1) ; search from left beql 20$ ; none there, done! movl r1,r2 ; save this pointer/ incl r1 ; start again one byte to the right decl r0 ; update new length! bgtr 10$ ; and continue search-20$: movl r2,r0 ; return last pointer found ret .end*[MAHAN.XTERM.LIB]X11.DIR;1+,wr./@ 4-or0123 KPWO56|R7R8T9G@HJI MAILEMPTY.xr MAILFULL.yr!*[MAHAN.XTERM.LIB.X11]MAILEMPTY.;1+,xr./@ 4aAiF-wr0123KPWO56AiF70WiF8!U9G@HJ/  XTERM021.BCKxrwr![MAHAN.XTERM.LIB.X11]MAILEMPTY.;1 V#define mailempty_width 48 #define mailempty_height 48 static char mailempty_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x80, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xc0, 0xaf, 0xaa, 0xaa, 0xaa, 0x7a, 0xe0, 0x57, 0x55, 0x55, 0x55, 0x7d, 0xf0, 0xaf, 0xaa, 0xaa, 0xaa, 0x7e, 0xf8, 0x57, 0x55, 0x55, 0x55, 0x7f, 0xfc, 0xaf, 0xaa, 0xaa, 0xaa, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xab, 0xaa, 0xaa, 0xea, 0x7f, 0xfe, 0x55, 0x55, 0x55, 0xf5, 0x6f, 0xfe, 0xaa, 0xaa, 0xaa, 0xea, 0x67, 0x7e, 0x55, 0x55, 0x55, 0xf5, 0x63, 0xbe, 0xaa, 0xaa, 0xaa, 0xea, 0x61, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x60, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0x60, 0x06, 0x06, 0x00, 0x00, 0x60, 0x60, 0x06, 0x06, 0x00, 0x00, 0x60, 0x60, 0x06, 0x06, 0x00, 0x00, 0x60, 0x60, 0x06, 0x06, 0x00, 0x00, 0x60, 0x60, 0x06, 0x06, 0x00, 0x00, 0x60, 0x60, 0x06, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0x06, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x86, 0xaf, 0xaa, 0xaa, 0xea, 0x7a, 0xc6, 0x57, 0x55, 0x55, 0x75, 0x7d, 0xe6, 0xaf, 0xaa, 0xaa, 0xea, 0x7e, 0xf6, 0x57, 0x55, 0x55, 0x75, 0x7f, 0xfe, 0xaf, 0xaa, 0xaa, 0xea, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xab, 0xaa, 0xaa, 0xea, 0x7f, 0xfe, 0x55, 0x55, 0x55, 0xf5, 0x6f, 0xfe, 0xaa, 0xaa, 0xaa, 0xea, 0x67, 0x7e, 0x55, 0x55, 0x55, 0xf5, 0x63, 0xbe, 0xaa, 0xaa, 0x- XTERM021.BCKxrwr![MAHAN.XTERM.LIB.X11]MAILEMPTY.;1aa, 0xea, 0x61, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x60, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0x60, 0x06, 0x06, 0x00, 0x00, 0x60, 0x00, 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};  *[MAHAN.XTERM.LIB.X11]MAILFULL.;1+,yr./@ 4^gF-wr0123KPWO56gF70=(F8nVU9G@HJ#define mailfull_width 48 #define mailfull_height 48 static char mailfull_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xff, 0xff, 0xff, 0x07, 0xc0, 0xff, 0xff, 0xff, 0x1f, 0x04, 0x40, 0x00, 0x00, 0x00, 0xd0, 0x05, 0x40, 0x00, 0x00, 0x00, 0x57, 0x7d, 0x40, 0x1e, 0x00, 0x00, 0x55, 0x7d, 0x40, 0x00, 0x00, 0x00, 0xd5, 0x7d, 0x60, 0x02, 0x00, 0x00, 0x17, 0x7c, 0x70, 0x00, 0x7e, 0x00, 0x10, 0x7c, 0x78, 0x00, 0x00, 0x00, 0x10, 0x7e, 0x7c, 0x00, 0x1e, 0x00, 0x10, 0x7f, 0x7e, 0x00, 0  XTERM021.BCKyrwr [MAHAN.XTERM.LIB.X11]MAILFULL.;1x00, 0x00, 0x90, 0x7f, 0x7e, 0x00, 0x3e, 0x07, 0xd0, 0x7f, 0x7e, 0x00, 0x00, 0x00, 0xf0, 0x7f, 0x7e, 0x00, 0x00, 0x00, 0xf0, 0x6f, 0x7e, 0x00, 0x00, 0x00, 0xf0, 0x67, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x63, 0xbe, 0xaa, 0xaa, 0xaa, 0xea, 0x61, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x60, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0x60, 0x06, 0x06, 0x00, 0x00, 0x60, 0x60, 0x06, 0x06, 0x00, 0x00, 0x60, 0x60, 0x06, 0x06, 0x00, 0x00, 0x60, 0x60, 0x06, 0x06, 0x00, 0x00, 0x60, 0x60, 0x06, 0x06, 0x00, 0x00, 0x60, 0x60, 0x06, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x86, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xc6, 0xaf, 0xaa, 0xaa, 0xea, 0x7a, 0xe6, 0x57, 0x55, 0x55, 0x75, 0x7d, 0xf6, 0xaf, 0xaa, 0xaa, 0xea, 0x7e, 0xfe, 0x57, 0x55, 0x55, 0x75, 0x7f, 0xfe, 0xaf, 0xaa, 0xaa, 0xea, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x7f, 0xfe, 0xab, 0xaa, 0xaa, 0xea, 0x7f, 0xfe, 0x55, 0x55, 0x55, 0xf5, 0x6f, 0xfe, 0xaa, 0xaa, 0xaa, 0xea, 0x67, 0x7e, 0x55, 0x55, 0x55, 0xf5, 0x63, 0xbe, 0xaa, 0xaa, 0xaa, 0xea, 0x61, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x60, 0xfe, 0xff, 0xff, 0xff, 0x7f, 0x60, 0x06, 0x06, 0x00, 0x00, 0x60, 0x60, 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x06, 0xee, 0x9c, 0x37, 0x60, 0x00, 0x06, 0xfe, 0x36, 0x33, 0x60, 0x00, 0x06, 0xd6, 0x3e, 0x33, 0x60, 0x00, 0x06, 0xc6, 0xb6, 0xf7, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};  XTERM021.BCKzror[MAHAN.XTERM.LIB]XAW.DIR;1*[MAHAN.XTERM.LIB]XAW.DIR;1+,zr./@ 4 -or0123 KPWO56R7jAR8jU9G@HJI ASCIISINK.C{r ASCIISINK.H|r ASCIISINKP.H}r ASCIISRC.C ~r ASCIISRC.Hr ASCIISRCP.Hr ASCIITEXT.Cr ASCIITEXT.Hr ASCIITEXTP.HrBOX.CrBOX.HrBOXP.Hr CARDINALS.Hr CLOCK.CrCLOCK.HrCLOCKP.Hr  COMMAND.C r L8spfs n{5HPMMDb;1 ^=QKQr *-N0/T}yMWVG 8K~}M9 2ve/bA3C-eH9 *E #O6RKNu-BT>;;U<(_U gM]F(?z8wz aBA  Hch|Y/i_DUI0 n8KHNcNhb|-9ZZb}aoVr Xc&Qzc \e{c/h)7]-yAn|OR8G+o[gEA{@B9.>L%2>Tz2W:i CrMmUI%:Dd-1mULr^C'ixVXf*}.(fyqV- "9R}&x:(;j7Rm5^xc =jX#= g rddF5D8[A:Btf6s<}3}'>>!_yjLneED0O-e~o%cb9"C=\!J8Swc-'(wK37)& vj 2d N2rBIVdB 1< vBNiM J]y]e/(-"aM]F"/M'E)eu8Z(z k8mZQ~RZ~ mU%6,ev:JN@b SIH`NPzn[_KiFxXo7{s:}{L7N];W8 /Fcu.Em S^)pLzw A2~.MKRd;6.N?w*$l$"M4yf {EJ"n uM&7vi/@4{ MFc3 b0% V11]1Vvgf0$ 2Cq@ $ uHe)Vf]K\Z~a^g]f8MldCCM\dhS/dj#>Hy"OOX!)$f)Fy OED -.H@5&2yH+Hq\: `5 li m+iPLS#,SALn8o=X#\Nj=.rB!Y,=5lg,$&K<,9w*)E5W<*t!OP :b594a#6kT8iI<_%;9I1RwPq~V/~m"!_}a0& 9LL,x40|4|!oX .UsD8g{xH8Y]N$uK` Q`qx|z7K@ecI&srI7:., %dc0 A?/74>xi`;  S 7Fvwd@HJN XTERM021.BCKzror[MAHAN.XTERM.LIB]XAW.DIR;1 COMMAND.Hr  COMMANDI.Hr  COMMANDP.Hr  COPYRIGHT.Hr DIALOG.Cr DIALOG.Hr  DIALOGP.Hr FORM.CrFORM.Hr FORMP.HrGRIP.CrGRIP.HrGRIPP.HrLABEL.CrLABEL.HrLABELP.HrLIST.Cr LIST.HrLISTP.Hr LOGO.CrLOGO.HrLOGOP.Hr  MAILBOX.Cr  MAILBOX.Hr  MAILBOXP.Hr MAKE.COMrf XTERM021.BCKzror[MAHAN.XTERM.LIB]XAW.DIR;1~ MENUBUTTON.Cr  MENUBUTTON.Hr MENUBUTTOP.Hr PANED.CrPANED.Hr PANEDP.Hr SCROLL.Hr SCROLLBAR.Cr  SCROLLBAR.Hr SCROLLBARP.HrSIMPLE.CrSIMPLE.Hr SIMPLEMENP.Hr SIMPLEMENU.Cr SIMPLEMENU.Hr SIMPLEP.Hr SME.Cr SME.HrSMEBSB.CrSMEBSB.Hr SMEBSBP.Hr  SMELINE.Cr SMELINE.Hr  SMELINEP.HrSMEP.Hr  STRIPCHARP.Hrg\ XTERM021.BCKzror[MAHAN.XTERM.LIB]XAW.DIR;1  STRIPCHART.Cr STRIPCHART.Hr TEMPLATE.Cr TEMPLATE.Hr  TEMPLATEP.Hr TEXT.C rTEXT.Hr TEXTACTION.CrTEXTP.Hr  TEXTPOP.Cr TEXTSINK.Cr TEXTSINK.Hr TEXTSINKP.Hr  TEXTSRC.Cr TEXTSRC.Hr  TEXTSRCP.HrTEXTTR.CrTOGGLE.Cr TOGGLE.Hr TOGGLEP.HrVENDOR.Cr VIEWPORT.Cr  VIEWPORT.Hr VIEWPORTP.HrVPANED.Hr  XAWINIT.Cr  XAWINIT.Hr u. XTERM021.BCK{rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2[#M"*[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2+,{r.#/@ 4[#"cpF-zr0123KPWO#56pF7OF8pU9G@HJ#if (!defined(lint) && !defined(SABER)) static char Xrcsid[] = "$XConsortium: AsciiSink.c,v 1.49 89/12/14 19:15:55 converse Exp $"; #endif /* lint && SABER */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved 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, and that the names of Digital or MIT not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT` XTERM021.BCK{rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2[# SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ #define XAW_ASCII_SINK_OBJECT #include #ifdef vax11c #include #include #include #include #include #include "XawInit.h" #include "AsciiSinkP.h" #include "AsciiSrcP.h" /* For source function defs. */ #include "TextP.h" /* I also reach into the text widget. */ #else #include #include #include #include #include #include #include #include /* For source function defs. */ #include /* I also reach into the text widget. */ #endif /* vax11c */ #ifdef GETLASTPOS #undef GETLASTPOS /* We will use our own GETLASTPOS. */ #endif #define GETLASTPOS XawTextSourceScan(source, 0, XawstAll, XawsdRight, 1, TRUE) static void Initialize(), Destroy(); static Boolean SetValues(); static void DisplayText(), InsertCursor(), FindPosition(); static void FindDistance(), Resolve(), GetCursorBounds(); #define offset(field) XtOffset(AsciiSinkObject, ascii_sink.field) static XtResourceeM XTERM021.BCK{rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2[# resources[] = { {XtNecho, XtCOutput, XtRBoolean, sizeof(Boolean), offset(echo), XtRImmediate, (caddr_t) True}, {XtNdisplayNonprinting, XtCOutput, XtRBoolean, sizeof(Boolean), offset(display_nonprinting), XtRImmediate, (caddr_t) True}, }; #undef offset #define SuperClass (&textSinkClassRec) #ifdef vax11c globaldef {"asciisinkclassrec"} noshare #endif /* vax11c */ AsciiSinkClassRec asciiSinkClassRec = { { /* core_class fields */ /* superclass */ (WidgetClass) SuperClass, /* class_name */ "AsciiSink", /* widget_size */ sizeof(AsciiSinkRec), /* class_initialize */ XawInitializeWidgetSet, /* class_part_initialize */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* obj1 */ NULL, /* obj2 */ NULL, /* obj3 */ 0, /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* obj4 */ FALSE, /* obj5 */ FALSE, /* obj6 */ FALSE, /* obj7 */ FALSE, /* destroy */ Destroy, /* obj8 */ NULL, /* obj9 */ NULL, /* set_values */ SetValues, /* set_values_hook */ NULL, /* obj10 */ NULL, /* get_values_hook */ NULL, /* obj11 */ NULL, /* version */ XtVersion, /* callback_private */ NULL, /* obj12 */ NULL, /* obj13 */ NULL, /* obj14 */ NULL, /* extension */ NULL }, /* text_sink_class fields */ { /* DisplayText "0 XTERM021.BCK{rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2[#z' */ DisplayText, /* InsertCursor */ InsertCursor, /* ClearToBackground */ XtInheritClearToBackground, /* FindPosition */ FindPosition, /* FindDistance */ FindDistance, /* Resolve */ Resolve, /* MaxLines */ XtInheritMaxLines, /* MaxHeight */ XtInheritMaxHeight, /* SetTabs */ XtInheritSetTabs, /* GetCursorBounds */ GetCursorBounds }, /* ascii_sink_class fields. */ { /* Keep Compiler happy. */ NULL } }; #ifdef vax11c globaldef {"asciisinkobjectclass"} noshare #endif /* vax11c */ WidgetClass asciiSinkObjectClass = (WidgetClass)&asciiSinkClassRec; /* Utilities */ static int CharWidth (w, x, c) Widget w; int x; unsigned char c; { register int i, width, nonPrinting; AsciiSinkObject sink = (AsciiSinkObject) w; XFontStruct *font = sink->text_sink.font; Position *tab; if ( c == LF ) return(0); if (c == TAB) { /* Adjust for Left Margin. */ x -= ((TextWidget) XtParent(w))->text.margin.left; if (x >= XtParent(w)->core.width) return 0; for (i = 0, tab = sink->text_sink.tabs ; i < sink->text_sink.tab_count ; i++, tab++) { if (x < *tab) { if (*tab < XtParent(w)->core.width) return *tab - x; else return 0; } } return 0; } if ( (nonPrinting = (c < (unsigned char) SP)) ) if (sink->ascii_sink.display_nonprinting) c += '@'; ) XTERM021.BCK{rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2[# else { c = SP; nonPrinting = False; } if (font->per_char && (c >= font->min_char_or_byte2 && c <= font->max_char_or_byte2)) width = font->per_char[c - font->min_char_or_byte2].width; else width = font->min_bounds.width; if (nonPrinting) width += CharWidth(w, x, (unsigned char) '^'); return width; } /* Function Name: PaintText * Description: Actually paints the text into the windoe. * Arguments: w - the text widget. * gc - gc to paint text with. * x, y - location to paint the text. * buf, len - buffer and length of text to paint. * Returns: the width of the text painted, or 0. * * NOTE: If this string attempts to paint past the end of the window * then this function will return zero. */ static Dimension PaintText(w, gc, x, y, buf, len) Widget w; GC gc; Position x, y; unsigned char * buf; int len; { AsciiSinkObject sink = (AsciiSinkObject) w; TextWidget ctx = (TextWidget) XtParent(w); Position max_x; Dimension width = XTextWidth(sink->text_sink.font, (char *) buf, len); max_x = (Position) ctx->core.width; if ( ((int) width) <= -x) /* Don't draw if we can't see it. */ return(width); XDrawImageString(XtDisplay(ctx), XtWindow(ctx), gc, (int) x, (int) y, (char *) buf, len); if ( (((Position) width + x) > max_x) && (ctx->text.margin.right != 0) ) { x = ctx->core.width - ctx->text.margin.right; width = ctx->text.margin.right; XFillRectangle(XtDisplay((U~. XTERM021.BCK{rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2[#CTWidget) ctx), XtWindow( (Widget) ctx), sink->ascii_sink.normgc, (int) x, (int) y - sink->text_sink.font->ascent, (unsigned int) width, (unsigned int) (sink->text_sink.font->ascent + sink->text_sink.font->descent)); return(0); } return(width); } /* Sink Object Functions */ /* * This function does not know about drawing more than one line of text. */ static void DisplayText(w, x, y, pos1, pos2, highlight) Widget w; Position x, y; Boolean highlight; XawTextPosition pos1, pos2; { AsciiSinkObject sink = (AsciiSinkObject) w; Widget source = XawTextGetSource(XtParent(w)); unsigned char buf[BUFSIZ]; int j, k; XawTextBlock blk; GC gc = highlight ? sink->ascii_sink.invgc : sink->ascii_sink.normgc; GC invgc = highlight ? sink->ascii_sink.normgc : sink->ascii_sink.invgc; if (!sink->ascii_sink.echo) return; y += sink->text_sink.font->ascent; for ( j = 0 ; pos1 < pos2 ; ) { pos1 = XawTextSourceRead(source, pos1, &blk, pos2 - pos1); for (k = 0; k < blk.length; k++) { if (j >= BUFSIZ) { /* buffer full, dump the text. */ x += PaintText(w, gc, x, y, buf, j); j = 0; } buf[j] = blk.ptr[k]; if (buf[j] == LF) /* line feeds ('\n') are not printed. */ continue; else if (buf[j] == '\t') { Position temp = 0; Dimension width; if ((j != 0) && ((temp = PaintText(w, gc, x, y, buf, j)) == 0)) return; x += temp; width = CharWidth(w, x, (unsigned char) '\S  XTERM021.BCK{rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2[#Xt'); XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w), invgc, (int) x, (int) y - sink->text_sink.font->ascent, (unsigned int) width, (unsigned int) (sink->text_sink.font->ascent + sink->text_sink.font->descent)); x += width; j = -1; } else if ( buf[j] < (unsigned char) ' ' ) { if (sink->ascii_sink.display_nonprinting) { buf[j + 1] = buf[j] + '@'; buf[j] = '^'; j++; } else buf[j] = ' '; } j++; } } if (j > 0) (void) PaintText(w, gc, x, y, buf, j); } #define insertCursor_width 6 #define insertCursor_height 3 static char insertCursor_bits[] = {0x0c, 0x1e, 0x33}; static Pixmap CreateInsertCursor(s) Screen *s; { return (XCreateBitmapFromData (DisplayOfScreen(s), RootWindowOfScreen(s), insertCursor_bits, insertCursor_width, insertCursor_height)); } /* Function Name: GetCursorBounds * Description: Returns the size and location of the cursor. * Arguments: w - the text object. * RETURNED rect - an X rectangle to return the cursor bounds in. * Returns: none. */ static void GetCursorBounds(w, rect) Widget w; XRectangle * rect; { AsciiSinkObject sink = (AsciiSinkObject) w; rect->width = (unsigned short) insertCursor_width; rect->height = (unsigned short) insertCursor_height; rect->x = sink->ascii_sink.cursor_x - (short) (rect->width / 2); rect->y = sink->ascii_sink.cursor_y - (short) rect->height; } /* * The following procedure manages the Qz8ssrxSINK.C;2 [,Qq"^ite0>cw*c00pGU^hx F3.WBr }w >"0R>~v K>8Yn~1 SZ? g(z`+<>hK=$1*{F[L{w[JDzx+Bw ^< P u*wVUGY_ifr'CS DZI՝yN'c-i{Y3#(N +70`ZGWe,B*4amAV6', h;/FI[\4(NW\qg(#Eu`F#y!"y /=GwJ*FK'xFJP{SP/ ~D"C$! $lMsyfs`%i!~mPqum8-lekti'kUdqv$E YZ=xQin]%PTliw )6JQW 7@ &2\N=@ml'e$bi,vK\7)=N|5 OTL7" 2*H m$l GzRsBpa5E_d1?=O: 2;{L5^yx0&W,G#yJ>q2CU9V0'/dVF-OEW5"[b ?oYgc6^s}yU/KO}s,e|}%)vj9G#sR 2 3b(]"{!:0O&\uh) Vn1h 8 EsE%Fw@>U 'O34(S?Qt,eFC =;#B>z{uQjEpMRk& 0`#i)xYiyU,CH@jxc ^v #KB?)6YZzV'qkIk8UGCO19EUHfx9W 6334'c/0r}:%y{{0}v%OsR)3t? s ?~)qI^ mt ,S,Kgl{3!bdZRPGz1.JX;N zr_ۓn3dzeB,B*[S_BJO1 &*@B2 9"G) i|x\EQJ]6 1g(?dO|=!chXF@*OCzd0>. DtfO-0Y9 7jT 90R\fKvTM ./1(OJ=( RL<(]iu&X R {c: ~dg)0SeS)uw]jEmFJ>? I|Aj;c},Gn]T %IMH(i /';SK`<=vhqsQ?&z"1NX#  XTERM021.BCK{rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2[#+"insert" cursor. */ static void InsertCursor (w, x, y, state) Widget w; Position x, y; XawTextInsertState state; { AsciiSinkObject sink = (AsciiSinkObject) w; Widget text_widget = XtParent(w); XRectangle rect; sink->ascii_sink.cursor_x = x; sink->ascii_sink.cursor_y = y; GetCursorBounds(w, &rect); if (state != sink->ascii_sink.laststate && XtIsRealized(text_widget)) XCopyPlane(XtDisplay(text_widget), sink->ascii_sink.insertCursorOn, XtWindow(text_widget), sink->ascii_sink.xorgc, 0, 0, (unsigned int) rect.width, (unsigned int) rect.height, (int) rect.x, (int) rect.y, 1); sink->ascii_sink.laststate = state; } /* * Given two positions, find the distance between them. */ static void FindDistance (w, fromPos, fromx, toPos, resWidth, resPos, resHeight) Widget w; XawTextPosition fromPos; /* First position. */ int fromx; /* Horizontal location of first position. */ XawTextPosition toPos; /* Second position. */ int *resWidth; /* Distance between fromPos and resPos. */ XawTextPosition *resPos; /* Actual second position used. */ int *resHeight; /* Height required. */ { AsciiSinkObject sink = (AsciiSinkObject) w; Widget source = XawTextGetSource(XtParent(w)); register XawTextPosition index, lastPos; register unsigned char c; XawTextBlock blk; /* we may not need this */ lastPos = GETLASTPOS; XawTextSourceRead(source, fromPos, &blk, toPos - fromPos); *resWidth = 0; for (index = fromPos; index != toPos && indeh> XTERM021.BCK{rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2[#1x < lastPos; index++) { if (index - blk.firstPos >= blk.length) XawTextSourceRead(source, index, &blk, toPos - fromPos); c = blk.ptr[index - blk.firstPos]; *resWidth += CharWidth(w, fromx + *resWidth, c); if (c == LF) { index++; break; } } *resPos = index; *resHeight = sink->text_sink.font->ascent +sink->text_sink.font->descent; } static void FindPosition(w, fromPos, fromx, width, stopAtWordBreak, resPos, resWidth, resHeight) Widget w; XawTextPosition fromPos; /* Starting position. */ int fromx; /* Horizontal location of starting position.*/ int width; /* Desired width. */ int stopAtWordBreak; /* Whether the resulting position should be at a word break. */ XawTextPosition *resPos; /* Resulting position. */ int *resWidth; /* Actual width used. */ int *resHeight; /* Height required. */ { AsciiSinkObject sink = (AsciiSinkObject) w; Widget source = XawTextGetSource(XtParent(w)); XawTextPosition lastPos, index, whiteSpacePosition; int lastWidth, whiteSpaceWidth; Boolean whiteSpaceSeen; unsigned char c; XawTextBlock blk; lastPos = GETLASTPOS; XawTextSourceRead(source, fromPos, &blk, BUFSIZ); *resWidth = 0; whiteSpaceSeen = FALSE; c = 0; for (index = fromPos; *resWidth <= width && index < lastPos; index++) { lastWidth = *resWidth; if (index - blk.firstPos >= blk.length) XawTextSourceRead(source, index, &blk, BUFSIZ); c = blk.ptr[index - blk.firstPos]; *resWidth += CharWidth(w, fromx + *resWidth, ?)g XTERM021.BCK{rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2[#2c); if ((c == SP || c == TAB) && *resWidth <= width) { whiteSpaceSeen = TRUE; whiteSpacePosition = index; whiteSpaceWidth = *resWidth; } if (c == LF) { index++; break; } } if (*resWidth > width && index > fromPos) { *resWidth = lastWidth; index--; if (stopAtWordBreak && whiteSpaceSeen) { index = whiteSpacePosition + 1; *resWidth = whiteSpaceWidth; } } if (index == lastPos && c != LF) index = lastPos + 1; *resPos = index; *resHeight = sink->text_sink.font->ascent +sink->text_sink.font->descent; } static void Resolve (w, pos, fromx, width, leftPos, rightPos) Widget w; XawTextPosition pos; int fromx, width; XawTextPosition *leftPos, *rightPos; { int resWidth, resHeight; Widget source = XawTextGetSource(XtParent(w)); FindPosition(w, pos, fromx, width, FALSE, leftPos, &resWidth, &resHeight); if (*leftPos > GETLASTPOS) *leftPos = GETLASTPOS; *rightPos = *leftPos; } static void GetGC(sink) AsciiSinkObject sink; { XtGCMask valuemask = (GCFont | GCGraphicsExposures | GCForeground | GCBackground ); XGCValues values; values.font = sink->text_sink.font->fid; values.graphics_exposures = (Bool) FALSE; values.foreground = sink->text_sink.foreground; values.background = sink->text_sink.background; sink->ascii_sink.normgc = XtGetGC((Widget)sink, valuemask, &values); values.foreground = sink->text_sink.background; values.background = sink->text_sink.foreground; sink->ascii_sink>Ƚ XTERM021.BCK{rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2[#.invgc = XtGetGC((Widget)sink, valuemask, &values); values.function = GXxor; values.background = (unsigned long) 0L; /* (pix ^ 0) = pix */ values.foreground = (sink->text_sink.background ^ sink->text_sink.foreground); valuemask = GCFunction | GCForeground | GCBackground; sink->ascii_sink.xorgc = XtGetGC((Widget)sink, valuemask, &values); } /***** Public routines *****/ /* Function Name: Initialize * Description: Initializes the TextSink Object. * Arguments: request, new - the requested and new values for the object * instance. * Returns: none. * */ /* ARGSUSED */ static void Initialize(request, new) Widget request, new; { AsciiSinkObject sink = (AsciiSinkObject) new; GetGC(sink); sink->ascii_sink.insertCursorOn= CreateInsertCursor(XtScreenOfObject(new)); sink->ascii_sink.laststate = XawisOff; sink->ascii_sink.cursor_x = sink->ascii_sink.cursor_y = 0; } /* Function Name: Destroy * Description: This function cleans up when the object is * destroyed. * Arguments: w - the AsciiSink Object. * Returns: none. */ static void Destroy(w) Widget w; { AsciiSinkObject sink = (AsciiSinkObject) w; XtReleaseGC(w, sink->ascii_sink.normgc); XtReleaseGC(w, sink->ascii_sink.invgc); XtReleaseGC(w, sink->ascii_sink.xorgc); XFreePixmap(XtDisplayOfObject(w), sink->ascii_sink.insertCursorOn); } /* Function Name: SetValues * Description: Sets the values for the AsciiSink * Arguments: current `] XTERM021.BCK{rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.C;2[#9A!- current state of the object. * request - what was requested. * new - what the object will become. * Returns: True if redisplay is needed. */ /* ARGSUSED */ static Boolean SetValues(current, request, new) Widget current, request, new; { AsciiSinkObject w = (AsciiSinkObject) new; AsciiSinkObject old_w = (AsciiSinkObject) current; if (w->text_sink.font != old_w->text_sink.font) { XtReleaseGC(w, w->ascii_sink.normgc); XtReleaseGC(w, w->ascii_sink.invgc); GetGC(w); ((TextWidget)XtParent(new))->text.redisplay_needed = True; } else { if ( (w->ascii_sink.echo != old_w->ascii_sink.echo) || (w->ascii_sink.display_nonprinting != old_w->ascii_sink.display_nonprinting) ) ((TextWidget)XtParent(new))->text.redisplay_needed = True; } return False; } "*[MAHAN.XTERM.LIB.XAW]ASCIISINK.H;3+,|r. /@ 4N @[#F-zr0123KPWO56@[#F7sFF8RV9G@HJ8 XTERM021.BCK|rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.H;3N /* * $XConsortium: AsciiSink.h,v 1.3 89/11/01 17:33:17 kit Exp $ */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved 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, and that the names of Digital or MIT not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ #ifndef _XawAsciiSink_h #define _XawAsciiSink_h /*********************************************************************** * * AsciiSink Object * ***********************************************************************/ #ifdef vax11/j XTERM021.BCK|rzr"[MAHAN.XTERM.LIB.XAW]ASCIISINK.H;3N ݨc #include "TextSink.h" #else #include #endif /* vax11c */ /* Resources: Name Class RepType Default Value ---- ----- ------- ------------- echo Output Boolean True displayNonprinting Output Boolean True */ #define XtCOutput "Output" #define XtNdisplayNonprinting "displayNonprinting" #define XtNecho "echo" /* Class record constants */ #ifndef XAW_ASCII_SINK_OBJECT #ifdef vax11c globalref WidgetClass asciiSinkObjectClass; #else extern WidgetClass asciiSinkObjectClass; #endif /* vax11c */ #endif /* !XAW_ASCII_SINK_OBJECT */ typedef struct _AsciiSinkClassRec *AsciiSinkObjectClass; typedef struct _AsciiSinkRec *AsciiSinkObject; /************************************************************ * * Public Functions. * ************************************************************/ #ifdef XAW_BC /************************************************************ * For Compatability Only. #define XtAsciiSinkCreate XawAsciiSinkCreate #define XtAsciiSinkDestroy XawAsciiSinkDestroy #define XawTextSink Widget #define XtTextSink XawTextSink extern XawTextSink XawAsciiSinkCreate(); /* parent, args, num_args */ /* Widget parent; */ /* ArgList args; */ /* Cardinal num_args; */ #define XawAsciiSinkDestroy XtDestroyWidget #endif /* XAW_BC */ #endif /* _XawAsciiSrc_h */ /* DON'T ADD STUFF AFTER THIS #endif */ ~ XTERM021.BCK}rzr#[MAHAN.XTERM.LIB.XAW]ASCIISINKP.H;3N #*[MAHAN.XTERM.LIB.XAW]ASCIISINKP.H;3+,}r. /@ 4N "F-zr0123KPWO56F7F8bV9G@HJ/* * $XConsortium: AsciiSinkP.h,v 1.2 89/10/04 13:56:34 kit Exp $ */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved 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, and that the names of Digital or MIT not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGE@ XTERM021.BCK}rzr#[MAHAN.XTERM.LIB.XAW]ASCIISINKP.H;3N ;S WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ /* * asciiSinkP.h - Private definitions for asciiSink object * */ #ifndef _XawAsciiSinkP_h #define _XawAsciiSinkP_h /*********************************************************************** * * AsciiSink Object Private Data * ***********************************************************************/ #ifdef vax11c #include "TextSinkP.h" #include "AsciiSink.h" #else #include #include #endif /* vax11c */ /************************************************************ * * New fields for the AsciiSink object class record. * ************************************************************/ typedef struct _AsciiSinkClassPart { int foo; } AsciiSinkClassPart; /* Full class record declaration */ typedef struct _AsciiSinkClassRec { ObjectClassPart object_class; TextSinkClassPart text_sink_class; AsciiSinkClassPart ascii_sink_class; } AsciiSinkClassRec; #ifndef XAW_ASCII_SINK_OBJECT #ifdef vax11c globalref AsciiSinkClassRec asciiSinkClassRec; #else extern AsciiSinkClassRec asciiSinkClassRec; #endif /* vax11c */ #endif /* !XAW_ASCII_SINK_OBJECT */ /* New fields for the AsciiSink object record */ typedef struct { /* public resources */ Boolean echo; Boolean displahO XTERM021.BCK}rzr#[MAHAN.XTERM.LIB.XAW]ASCIISINKP.H;3N hy_nonprinting; /* private state */ GC normgc, invgc, xorgc; Pixmap insertCursorOn; XawTextInsertState laststate; short cursor_x, cursor_y; /* Cursor Location. */ } AsciiSinkPart; /**************************************************************** * * Full instance record declaration * ****************************************************************/ typedef struct _AsciiSinkRec { ObjectPart object; TextSinkPart text_sink; AsciiSinkPart ascii_sink; } AsciiSinkRec; #endif /* _XawAsciiSinkP_h */ "*[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12+,~r.K/@ 4UKH;F-zr0123KPWOI56;F7BF8PW9G@HJQ~ms 3))]wW4Wl%I< :%zcX ng;j [PC\fXB9BW$i+1`b|+?<>[L+"[ p'1j]\-FQ5G h]/F9RW@W0CqN8E`h\ X$F~o3qCX0'p=N C:Pzs( X*&Ab 9p6l`<7fcTndTX#kcDyd+*+E3bk'en {MAI7GmySUUQFHm)$% P_7>b_V:)bca.H]d j|'c 7d(9U0&$:(\~x_$ YzV:Tu%;$q@T:xn_bcb*cTa{Ja0)^q _}y8bAc`8\H]yL[w@jTbRY%@sHX a o%b]q ?Lg|KKy7 V2>|# yuV) !='NQu&S)zK}\h*HCu=]-_7 &>P$tFr$JR]o0_QzE/qfn.e-Wlj/'z 54MC)h>V!Lgn!+rMJc6WI dav^EL=Leytgzw4P/=3dH/* @Y^IM{u(rd Q=C;]}5+j*6GAEx/rf943sjG|zftkXS({%jG{y1\.8^?JlXn5u]t @ 7#SIbOKOZx4<6:]ai@3id7+*3\q4]c/MW0&Bq']%4l7+M ;.=n=d)n8HWIEL!4(#e^ 1[-oN"Y7Vc6q4;T4t$WCt.8rgi,2;o_{"T{?0hx};dR@{7xD $2T_^J2h~c4[n]Q t??Zxog$36`-^X3M1LF$pM6>UC==}^ +Zl!j" M2`bCR_\:+E:czu1y 6[=+7/! / ;\Ry>&Ei_ e/Zr\*;iwf" '01E;Tq:j&^ajk,H~F \- ^I *uz@_SK*^j9HTlTyG7i"JyS{*E.o!0D XQR"_.ImJGXBuwSAM>&1|4MgTRKJG*BUi>@,4OfOwBJlcRIkU2R_,WGW{SI/G'|BR@NC?Z2E@X+v ^0 XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UKG#if ( !defined(lint) && !defined(SABER) ) static char Xrcsid[] = "$XConsortium: AsciiSrc.c,v 1.26 89/12/07 18:35:14 kit Exp $"; #endif /* * Copyright 1989 Massachusetts Institute of Technology * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that * the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting * documentation, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T. * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * * Author: Chris Peterson, MIT X Consortium. * * Much code taken from X11R3 String and Disk Sources. */ /* * AsciiSrc.c - AsciiSrc object. (For use with the text widget). * */ #define XAW_ASCII_SRC_OBJECT #include #include #ifdef vax11c #include #include #include "XawInit.h" #include "AsciiSrcP.h" #include #include #else #include #include #include #include #include #include #endif /* vax11c */ #if (defined(ASCII_STRING) || defined(ASCII_DISK)) #ifdef vax11c # include "AsciiText.h" #else # include /* for Widget Classes. */ #endif /* vax11c */ #endif /**************************************************************** * * Full class record constant * ****************************************************************/ /* Private Data */ static int magic_value = MAGIC_VALUE; #define offset(field) XtOffset(AsciiSrcObject, ascii_src.field) static XtResource resources[] = { {XtNstring, XtCString, XtRString, sizeof (char *), offset(string), XtRString, NULL}, {XtNtype, XtCType, XtRAsciiType, sizeof (XawAsciiType), offset(type), XtRImmediate, (XtPointer)XawAsciiString}, {XtNdataCompression, XtCDataCompression, XtRBoolean, sizeof (Boolean), offset(data_compression), XtRImmediate, (XtPointer) TRUE}, {XtNpieceSize, XtCPieceSize, XtRInt, sizeof (XawTextPosition), offset(piece_size), XtRImmediate, (XtPointer) BUFSIZ}, {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer), offset(callback), XtRCallback, (XtPointer)NULL}, {XtNuseStringInPlace, Xt~E XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK~CUseStringInPlace, XtRBoolean, sizeof (Boolean), offset(use_string_in_place), XtRImmediate, (XtPointer) FALSE}, {XtNlength, XtCLength, XtRInt, sizeof (int), offset(ascii_length), XtRInt, (XtPointer) &magic_value}, #ifdef ASCII_DISK {XtNfile, XtCFile, XtRString, sizeof (String), offset(filename), XtRString, NULL}, #endif /* ASCII_DISK */ }; static XawTextPosition Scan(), Search(), ReadText(); static int ReplaceText(); static Piece * FindPiece(), * AllocNewPiece(); static FILE * InitStringOrFile(); static void FreeAllPieces(), RemovePiece(), BreakPiece(), LoadPieces(); static void RemoveOldStringOrFile(), CvtStringToAsciiType(); static void ClassInitialize(), Initialize(), Destroy(), GetValuesHook(); static String MyStrncpy(), StorePiecesInString(); static Boolean SetValues(), WriteToFile(); extern char *tmpnam(); void bcopy(); #ifdef vax11c extern volatile noshare int errno; extern noshare int sys_nerr; extern noshare char* sys_errlist[]; #else extern int errno, sys_nerr; extern char* sys_errlist[]; #endif /* vax11c */ #define superclass (&textSrcClassRec) #ifdef vax11c globaldef {"asciisrcclassrec"} noshare #endif /* vax11c */ AsciiSrcClassRec asciiSrcClassRec = { { /* object_class fields */ /* superclass */ (WidgetClass) superclass, /* class_name */ "AsciiSrc", /* widget_size */ sizeof(AsciiSrcRec), /* class_initialize */ ClassInitialize, /* class_part_initialize */ NULL, /* class_inited */ FALSE, /* initialize */ Initializ XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK e, /* initialize_hook */ NULL, /* obj1 */ NULL, /* obj2 */ NULL, /* obj3 */ 0, /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* obj4 */ FALSE, /* obj5 */ FALSE, /* obj6 */ FALSE, /* obj7 */ FALSE, /* destroy */ Destroy, /* obj8 */ NULL, /* obj9 */ NULL, /* set_values */ SetValues, /* set_values_hook */ NULL, /* obj10 */ NULL, /* get_values_hook */ GetValuesHook, /* obj11 */ NULL, /* version */ XtVersion, /* callback_private */ NULL, /* obj12 */ NULL, /* obj13 */ NULL, /* obj14 */ NULL, /* extension */ NULL }, /* textSrc_class fields */ { /* Read */ ReadText, /* Replace */ ReplaceText, /* Scan */ Scan, /* Search */ Search, /* SetSelection */ XtInheritSetSelection, /* ConvertSelection */ XtInheritConvertSelection }, /* asciiSrc_class fields */ { #ifdef vax11c /* Keep the compiler happy */ 0 #else /* Keep the compiler happy */ NULL #endif /* vax11c */ } }; #ifdef vax11c globaldef {"asciisrcobjectclass"} noshare #endif /* vax11c */ WidgetClass asciiSrcObjectClass = (WidgetClass)&asciiSrcClassRec; /************************************************************ * * Semi-Public Interfaces. * ***************************: XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK5k *********************************/ /* Function Name: ClassInitialize * Description: Class Initialize routine, called only once. * Arguments: none. * Returns: none. */ static void ClassInitialize() { XawInitializeWidgetSet(); XtAddConverter( XtRString, XtRAsciiType, CvtStringToAsciiType, NULL, (Cardinal) 0); } /* Function Name: Initialize * Description: Initializes the simple menu widget * Arguments: request - the widget requested by the argument list. * new - the new widget with both resource and non * resource values. * Returns: none. */ /* ARGSUSED */ static void Initialize(request, new) Widget request, new; { AsciiSrcObject src = (AsciiSrcObject) new; FILE * file; /* * Set correct flags (override resources) depending upon widget class. */ #ifdef ASCII_DISK if (XtIsSubclass(XtParent(new), asciiDiskWidgetClass)) { src->ascii_src.type = XawAsciiFile; src->ascii_src.string = src->ascii_src.filename; } #endif #ifdef ASCII_STRING if (XtIsSubclass(XtParent(new), asciiStringWidgetClass)) { src->ascii_src.use_string_in_place = TRUE; src->ascii_src.type = XawAsciiString; } #endif src->ascii_src.changes = FALSE; src->ascii_src.allocated_string = FALSE; file = InitStringOrFile(src); LoadPieces(src, file, NULL); if (file != NULL) fclose(file); if ( src->ascii_src.type == XawAsciiString ) src->ascii_src.string = NULL; } /* Function Name: ReadText * Description:M XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK This function reads the source. * Arguments: w - the AsciiSource widget. * pos - position of the text to retreive. * RETURNED text - text block that will contain returned text. * length - maximum number of characters to read. * Returns: The number of characters read into the buffer. */ static XawTextPosition ReadText(w, pos, text, length) Widget w; XawTextPosition pos; XawTextBlock *text; int length; { AsciiSrcObject src = (AsciiSrcObject) w; XawTextPosition count, start; Piece * piece = FindPiece(src, pos, &start); text->firstPos = pos; text->ptr = piece->text + (pos - start); count = piece->used - (pos - start); text->length = (length > count) ? count : length; return(pos + text->length); } /* Function Name: ReplaceText. * Description: Replaces a block of text with new text. * Arguments: w - the AsciiSource widget. * startPos, endPos - ends of text that will be removed. * text - new text to be inserted into buffer at startPos. * Returns: XawEditError or XawEditDone. */ /*ARGSUSED*/ static int ReplaceText (w, startPos, endPos, text) Widget w; XawTextPosition startPos, endPos; XawTextBlock *text; { AsciiSrcObject src = (AsciiSrcObject) w; Piece *start_piece, *end_piece, *temp_piece; XawTextPosition start_first, end_first; int length, firstPos; /* * Editing a read only source is not allowed. */ if (src->text_src.edit_mode == XawtextRead) return(XawEditError); start_piece = FindPie5Um XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK ce(src, startPos, &start_first); end_piece = FindPiece(src, endPos, &end_first); src->ascii_src.changes = TRUE; /* We have changed the buffer. */ XtCallCallbacks(w, XtNcallback, NULL); /* * Remove Old Stuff. */ if (start_piece != end_piece) { temp_piece = start_piece->next; /* * If empty and not the only piece then remove it. */ if ( ((start_piece->used = startPos - start_first) == 0) && !((start_piece->next == NULL) && (start_piece->prev == NULL)) ) RemovePiece(src, start_piece); while (temp_piece != end_piece) { temp_piece = temp_piece->next; RemovePiece(src, temp_piece->prev); } end_piece->used -= endPos - end_first; if (end_piece->used != 0) MyStrncpy(end_piece->text, (end_piece->text + endPos - end_first), (int) end_piece->used); } else { /* We are fully in one piece. */ if ( (start_piece->used -= endPos - startPos) == 0) { if ( !((start_piece->next == NULL) && (start_piece->prev == NULL)) ) RemovePiece(src, start_piece); } else { MyStrncpy(start_piece->text + (startPos - start_first), start_piece->text + (endPos - start_first), (int) (start_piece->used - (startPos - start_first)) ); if ( src->ascii_src.use_string_in_place && ((src->ascii_src.length - (endPos - startPos)) < (src->ascii_src.piece_size - 1)) ) start_piece->text[src->ascii_src.length - (endPos - startPos)] = '\0'; } } src->ascii_src.length += -(endPos - startPos) + text->length; if ( text->length != 0) {  Z XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK= /* * Put in the New Stuff. */ start_piece = FindPiece(src, startPos, &start_first); length = text->length; firstPos = text->firstPos; while (length > 0) { char * ptr; int fill; if (src->ascii_src.use_string_in_place) { if (start_piece->used == (src->ascii_src.piece_size - 1)) { /* * If we are in ascii string emulation mode. Then the * string is not allowed to grow. */ start_piece->used = src->ascii_src.length = src->ascii_src.piece_size - 1; start_piece->text[src->ascii_src.length] = '\0'; return(XawEditError); } } if (start_piece->used == src->ascii_src.piece_size) { BreakPiece(src, start_piece); start_piece = FindPiece(src, startPos, &start_first); } fill = Min((int)(src->ascii_src.piece_size - start_piece->used), length); ptr = start_piece->text + (startPos - start_first); MyStrncpy(ptr + fill, ptr, (int) start_piece->used - (startPos - start_first)); strncpy(ptr, text->ptr + firstPos, fill); startPos += fill; firstPos += fill; start_piece->used += fill; length -= fill; } } if (src->ascii_src.use_string_in_place) start_piece->text[start_piece->used] = '\0'; return(XawEditDone); } /* Function Name: Scan * Description: Scans the text source for the number and type * of item specified. * Arguments: w - the AsciiSource widget. * posteV1 XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UKition - the position to start scanning. * type - type of thing to scan for. * dir - direction to scan. * count - which occurance if this thing to search for. * include - whether or not to include the character found in * the position that is returned. * Returns: the position of the item found. * * Note: While there are only 'n' characters in the file there are n+1 * possible cursor positions (one before the first character and * one after the last character. */ static XawTextPosition Scan (w, position, type, dir, count, include) Widget w; XawTextPosition position; XawTextScanType type; XawTextScanDirection dir; int count; Boolean include; { AsciiSrcObject src = (AsciiSrcObject) w; register int inc; Piece * piece; XawTextPosition first, first_eol_position; register char * ptr; if (type == XawstAll) { /* Optomize this common case. */ if (dir == XawsdRight) return(src->ascii_src.length); return(0); /* else. */ } if (position > src->ascii_src.length) position = src->ascii_src.length; if ( dir == XawsdRight ) { if (position == src->ascii_src.length) /* * Scanning right from src->ascii_src.length??? */ return(src->ascii_src.length); inc = 1; } else { if (position == 0) return(0); /* Scanning left from 0??? */ inc = -1; position--; } piece = FindPiece(src, position, &jY XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UKfirst); /* * If the buffer is empty then return 0. */ if ( piece->used == 0 ) return(0); ptr = (position - first) + piece->text; switch (type) { case XawstEOL: case XawstParagraph: case XawstWhiteSpace: for ( ; count > 0 ; count-- ) { Boolean non_space = FALSE, first_eol = TRUE; while (TRUE) { register unsigned char c = *ptr; ptr += inc; position += inc; if (type == XawstWhiteSpace) { if (isspace(c)) { if (non_space) break; } else non_space = TRUE; } else if (type == XawstEOL) { if (c == '\n') break; } else { /* XawstParagraph */ if (first_eol) { if (c == '\n') { first_eol_position = position; first_eol = FALSE; } } else if ( c == '\n') break; else if ( !isspace(c) ) first_eol = TRUE; } if ( ptr < piece->text ) { piece = piece->prev; if (piece == NULL) /* Begining of text. */ return(0); ptr = piece->text + piece->used - 1; } else if ( ptr >= (piece->text + piece->used) ) { piece = piece->next; if (piece == NULL) /* End of text. */ return(src->ascii_src.length); ptr = piece->text; } } } if (!include) { if ( type == XawstParagraph) position = first_eol_position; position -= inc; } break; case XawstPositions: position += count * inc; break; /* case XawstAll: ---- handled in special code above */ } if ( dir == XawsdLeft ) position++; if (position >= src->ascii_src.length) retYMDJ#]K2[o4e< &K_@v:uc^hi=*W+:I>RVOG& aeFEt29wDGaPEr[L'E+^?30!es 1{hL = *GYUs9b }nmZW=9Upy:.T 7Uu7]7Y6EG[Xu&aJ-n -l 985E Z+\;om<^B3Ow!`RxoLBI`dH' < SUgU>?:akAyOnf1 .}dIghMYPsAKr(z7?74?J!gN/t6aYLC) .3g~Y_-U4kPx5]@n))rV&I$%vZos*yfHk7ek X67WZd}K^e~=r~aNSrO4`#w3_nv}BI6PEEyX5o!0l)BS`);N#6uMxj}4F GkTaL/(!+F5U`#e`<hX8 y`u8>FXNCpz]]/Kfm'{Nqw3i \ksCmlK={Ukw% EX_~JIX8}*K\JYuS%+ a7!tL]$w ` cQ(ldAK|S&AOaji(Yo+KvohV+j[ 2t Jt Hg#C2KkhE,iw!VZ,T~`;yx1w:=DDV*Dc\U~<-vHF6\[Cpn FJUP/kx+" ^VLcQ[;J@*XE=/!e`2ltI%Ol,S6,_V{t\/*2,wiYMx]SWT~ %{\w!TsM=T;mkhC0Q2}^ pGV u#"W'; !Q~O}20[ 3oOJn/ls~qmGTN Sy. & 6WD^4J04 -Mj\Ia^@t;eIeyT J6V;6(C`7; .y$a(0Gr0l xK*x8o]Op\O7 hyTe:6 Wp $//#r;/@;&e`cT(+%13/h02_& v ,xtMSy6-l-,Q]z<)/S09WGz:hixx0vCti.lylr l{,S|CO=X6Gv? 7*D hqKLIRD:$`x u%)4{|n6o1bXV04GvJ?Cuk*P&V`0HX9rLw Eu l8)s"s}RG,{;oI TykH q>{P{.K)|R1l24Gp)T?qbj=gM>%ascii_src.length); if (position < 0) return(0); return(position); } /* Function Name: Search * Description: Searchs the text source for the text block passed * Arguments: w - the AsciiSource Widget. * position - the position to start scanning. * dir - direction to scan. * text - the text block to search for. * Returns: the position of the item found. */ static XawTextPosition Search(w, position, dir, text) Widget w; XawTextPosition position; XawTextScanDirection dir; XawTextBlock * text; { AsciiSrcObject src = (AsciiSrcObject) w; register int inc, count = 0; register char * ptr; Piece * piece; char * buf; XawTextPosition first; if ( dir == XawsdRight ) inc = 1; else { inc = -1; if (position == 0) return(XawTextSearchError); /* scanning left from 0??? */ position--; } buf = XtMalloc(sizeof(unsigned char) * text->length); strncpy(buf, (text->ptr + text->firstPos), text->length); piece = FindPiece(src, position, &first); ptr = (position - first) + piece->text; while (TRUE) { if (*ptr == ((dir == XawsdRight) ? *(buf + count) : *(buf + text->length - count - 1)) ) { if (count == (text->length - 1)) break; else count++; } else { if (count != 0) { position -=inc * count; ptr -= inc * count; } count = 0; } ptr += inc; position += inc; while ( ptr < piece->text ) { pie0B XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK"ce = piece->prev; if (piece == NULL) { /* Begining of text. */ XtFree(buf); return(XawTextSearchError); } ptr = piece->text + piece->used - 1; } while ( ptr >= (piece->text + piece->used) ) { piece = piece->next; if (piece == NULL) { /* End of text. */ XtFree(buf); return(XawTextSearchError); } ptr = piece->text; } } XtFree(buf); if (dir == XawsdLeft) return(position); return(position - (text->length - 1)); } /* Function Name: SetValues * Description: Sets the values for the AsciiSource. * Arguments: current - current state of the widget. * request - what was requested. * new - what the widget will become. * Returns: True if redisplay is needed. */ /* ARGSUSED */ static Boolean SetValues(current, request, new) Widget current, request, new; { AsciiSrcObject src = (AsciiSrcObject) new; AsciiSrcObject old_src = (AsciiSrcObject) current; Boolean total_reset = FALSE; FILE * file; if ( old_src->ascii_src.use_string_in_place != src->ascii_src.use_string_in_place ) { XtAppWarning( XtWidgetToApplicationContext(new), "AsciiSrc: The XtNuseStrinInPlace resources may not be changed."); src->ascii_src.use_string_in_place = old_src->ascii_src.use_string_in_place; } if ( (old_src->ascii_src.string != src->ascii_src.string) || (old_src->ascii_src.type != src->ascii_src.type) ) { if (old_src->ascii_src.string == src->ascii_src.string) { /* Fool it i( XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UKv %nto not freeing the string */ src->ascii_src.allocated_string = FALSE; RemoveOldStringOrFile(old_src); /* remove old info. */ src->ascii_src.allocated_string = TRUE; } else { RemoveOldStringOrFile(old_src); /* remove old info. */ src->ascii_src.allocated_string = FALSE; } file = InitStringOrFile(src); /* Init new info. */ LoadPieces(src, file, NULL); /* load new info into internal buffers. */ if (file != NULL) fclose(file); XawTextSetSource( XtParent(new), new, 0); /* Tell text widget what happened. */ if ( src->ascii_src.type == XawAsciiString ) src->ascii_src.string = NULL; total_reset = TRUE; } if ( old_src->ascii_src.ascii_length != src->ascii_src.ascii_length ) src->ascii_src.piece_size = src->ascii_src.ascii_length; if ( !total_reset && (old_src->ascii_src.piece_size != src->ascii_src.piece_size) ) { String string = StorePiecesInString(old_src); FreeAllPieces(old_src); LoadPieces(src, NULL, string); XtFree(string); } return(FALSE); } /* Function Name: GetValuesHook * Description: This is a get values hook routine that sets the * values specific to the ascii source. * Arguments: w - the AsciiSource Widget. * args - the argument list. * num_args - the number of args. * Returns: none. */ static void GetValuesHook(w, args, num_args) Widget w; ArgList args; Cardinal * num_args; { AsciiSrcObject src = O XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK((AsciiSrcObject) w; register int i; if (src->ascii_src.use_string_in_place) return; if (src->ascii_src.type == XawAsciiString) { for (i = 0; i < *num_args ; i++ ) if (streq(args[i].name, XtNstring)) { if (XawAsciiSave(w)) /* If save sucessful. */ *((char **) args[i].value) = src->ascii_src.string; break; } } } /* Function Name: Destroy * Description: Destroys an ascii source (frees all data) * Arguments: src - the Ascii source Widget to free. * Returns: none. */ static void Destroy (w) Widget w; { RemoveOldStringOrFile((AsciiSrcObject) w); } /************************************************************ * * Public routines * ************************************************************/ /* Function Name: XawAsciiSourceFreeString * Description: Frees the string returned by a get values call * on the string when the source is of type string. * Arguments: w - the AsciiSrc widget. * Returns: none. */ void XawAsciiSourceFreeString(w) Widget w; { AsciiSrcObject src = (AsciiSrcObject) w; if (src->ascii_src.allocated_string) { src->ascii_src.allocated_string = FALSE; XtFree(src->ascii_src.string); } } /* Function Name: XawAsciiSave * Description: Saves all the pieces into a file or string as required. * Arguments: w - the asciiSrc Widget. * Returns: TRUE if the save was successful. */ Boolean XawAsciiSave(w) Widget w; { AsciiSrcObject src = (AsciiSrcObject) w; /* * If using the string in place then there is no need+? XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK+ to play games * to get the internal info into a readable string. */ if (src->ascii_src.use_string_in_place) return(TRUE); if (src->ascii_src.type == XawAsciiFile) { char * string; if (!src->ascii_src.changes) /* No changes to save. */ return(TRUE); string = StorePiecesInString(src); if (WriteToFile(src, string, src->ascii_src.string) == FALSE) { XtFree(string); return(FALSE); } XtFree(string); } else { /* This is a string widget. */ if (src->ascii_src.allocated_string == TRUE) XtFree(src->ascii_src.string); else src->ascii_src.allocated_string = TRUE; src->ascii_src.string = StorePiecesInString(src); } src->ascii_src.changes = FALSE; return(TRUE); } /* Function Name: XawAsciiSaveAsFile * Description: Save the current buffer as a file. * Arguments: w - the AsciiSrc widget. * name - name of the file to save this file into. * Returns: True if the save was sucessful. */ Boolean XawAsciiSaveAsFile(w, name) Widget w; String name; { AsciiSrcObject src = (AsciiSrcObject) w; String string; Boolean ret; string = StorePiecesInString(src); ret = WriteToFile(src, string, name); XtFree(string); return(ret); } /* Function Name: XawAsciiSourceChanged * Description: Returns true if the source has changed since last saved. * Arguments: w - the ascii source widget. * Returns: a Boolean (see description). */ Boolean XawAsciiSourceChanged(w) Widget w; { return( ((AsciiSrcObject) w)-4k XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK'@.>ascii_src.changes ); } /************************************************************ * * Private Functions. * ************************************************************/ static void RemoveOldStringOrFile(src) AsciiSrcObject src; { FreeAllPieces(src); if (src->ascii_src.allocated_string) XtFree(src->ascii_src.string); } /* Function Name: WriteToFile * Description: Write the string specified to the begining of the file * specified. * Arguments: w - the widget. (for error messages only) * string - string to write. * name - the name of the file * file - file to write it to. * Returns: returns TRUE if sucessful, FALSE otherwise. */ static Boolean WriteToFile(src, string, name) AsciiSrcObject src; String string, name; { unsigned char buf[BUFSIZ]; int fd; if ( ((fd = creat(name, 0666)) == -1 ) || (write(fd, string, sizeof(unsigned char) * strlen(string)) == -1) ) { sprintf(buf, "Error, while attempting to write to the file %s.", name); XtAppWarning(XtWidgetToApplicationContext((Widget) src), buf); return(FALSE); } if ( close(fd) == -1 ) { sprintf(buf, "Error, while attempting to close the file %s.", name); XtAppWarning(XtWidgetToApplicationContext((Widget) src), buf); return(FALSE); } return(TRUE); } /* Function Name: StorePiecesInString * Description: store the pieces in memory into a standard ascii string. * Arguments: data - the ascii pointer data. * Retur XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK1ns: none. */ static String StorePiecesInString(src) AsciiSrcObject src; { String string; XawTextPosition first; Piece * piece; string = XtMalloc(sizeof(unsigned char) * src->ascii_src.length + 1); for (first = 0, piece = src->ascii_src.first_piece ; piece != NULL; first += piece->used, piece = piece->next) strncpy(string + first, piece->text, piece->used); string[src->ascii_src.length] = '\0'; /* NULL terminate this sucker. */ /* * This will refill all pieces to capacity. */ if (src->ascii_src.data_compression) { FreeAllPieces(src); LoadPieces(src, NULL, string); } return(string); } /* Function Name: InitStringOrFile. * Description: Initializes the string or file. * Arguments: src - the AsciiSource. * Returns: none - May exit though. */ static FILE * InitStringOrFile(src) AsciiSrcObject src; { char * open_mode; FILE * file; if (src->ascii_src.type == XawAsciiString) { if (src->ascii_src.string == NULL) src->ascii_src.length = 0; else src->ascii_src.length = strlen(src->ascii_src.string); if (src->ascii_src.use_string_in_place) { if (src->ascii_src.ascii_length == MAGIC_VALUE) src->ascii_src.piece_size = src->ascii_src.length; else src->ascii_src.piece_size = src->ascii_src.ascii_length + 1; } return(NULL); } /* * type is XawAsciiFile. */ src->ascii_src.is_tempfile = FALSE; switch (src->text_src.edit_mode) { case XawtextRead: if (src->ascii_src.string == NULL) XtErrorMsg(I XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK34"NoFile", "asciiSourceCreate", "XawError", "Creating a read only disk widget and no file specified.", NULL, 0); open_mode = "r"; break; case XawtextAppend: case XawtextEdit: if (src->ascii_src.string == NULL) { src->ascii_src.string = tmpnam (XtMalloc((unsigned)TMPSIZ)); src->ascii_src.is_tempfile = TRUE; } else { if (!src->ascii_src.allocated_string) { src->ascii_src.allocated_string = TRUE; src->ascii_src.string = XtNewString(src->ascii_src.string); } open_mode = "r+"; } break; default: XtErrorMsg("badMode", "asciiSourceCreate", "XawError", "Bad editMode for ascii source; must be Read, Append or Edit.", NULL, NULL); } if (!src->ascii_src.is_tempfile) { if ((file = fopen(src->ascii_src.string, open_mode)) == 0) { String params[2]; Cardinal num_params = 2; params[0] = src->ascii_src.string; if (errno <= sys_nerr) params[1] = sys_errlist[errno]; else { char msg[11]; sprintf(msg, "errno=%.4d", errno); params[1] = msg; } XtErrorMsg("openError", "asciiSourceCreate", "XawError", "Cannot open source file %s; %s", params, &num_params); } (void) fseek(file, 0L, 2); src->ascii_src.length = ftell (file); } else { src->ascii_src.length = 0; return(NULL); } return(file); } static void LoadPieces(src, file, string) AsciiSrcObject src; FILE * file; char * string; { char *local_str, *ptr; register int retbytes; register Piece * piece = NULL; XawJ XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK?7TextPosition left; if (string == NULL) { if (src->ascii_src.type == XawAsciiFile) { local_str = XtMalloc((src->ascii_src.length + 1) *sizeof(unsigned char)); if (src->ascii_src.length != 0) { fseek(file, 0L, 0); #ifdef vax11c retbytes = fread(local_str, sizeof(unsigned char), src->ascii_src.length, file); /* * The following is a HACK!!!!!, VAX C I/O retrieves the file * size by doing weird magic on the VBN value of the last block * of the file. However, this hardly ever jives with what * fread will see. The good point is that the difference is never * more than 512 bytes (1 VMS file block) difference. Maybe some- * day the folks a Nasuha will get it right. */ if (abs((src->ascii_src.length - retbytes)) > 512) XtErrorMsg("readError", "asciiSourceCreate", "XawError", "fread returned error.", NULL, NULL); #else if ( fread(local_str, sizeof(unsigned char), src->ascii_src.length, file) != src->ascii_src.length ) XtErrorMsg("readError", "asciiSourceCreate", "XawError", "fread returned error.", NULL, NULL); #endif /* vax11c */ } local_str[src->ascii_src.length] = '\0'; } else local_str = src->ascii_src.string; } else local_str = string; /* * If we are using teh string in place then set the other fields as follows: * * piece_size = length; * piece->used = src->ascii_src.length; */ if (src->ascii_src.use_string_in_place) { piece = AllocNewPiece(src, piece); piece->used = Min(src->ascii_src.length, < XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UKU:src->ascii_src.piece_size); piece->text = src->ascii_src.string; return; } ptr = local_str; left = src->ascii_src.length; do { piece = AllocNewPiece(src, piece); piece->text = XtMalloc(src->ascii_src.piece_size * sizeof(unsigned char)); piece->used = Min(left, src->ascii_src.piece_size); if (piece->used != 0) strncpy(piece->text, ptr, piece->used); left -= piece->used; ptr += piece->used; } while (left > 0); if ( (src->ascii_src.type == XawAsciiFile) && (string == NULL) ) XtFree(local_str); } /* Function Name: AllocNewPiece * Description: Allocates a new piece of memory. * Arguments: src - The AsciiSrc Widget. * prev - the piece just before this one, or NULL. * Returns: the allocated piece. */ static Piece * AllocNewPiece(src, prev) AsciiSrcObject src; Piece * prev; { Piece * piece = XtNew(Piece); if (prev == NULL) { src->ascii_src.first_piece = piece; piece->next = NULL; } else { if (prev->next != NULL) (prev->next)->prev = piece; piece->next = prev->next; prev->next = piece; } piece->prev = prev; return(piece); } /* Function Name: FreeAllPieces * Description: Frees all the pieces * Arguments: src - The AsciiSrc Widget. * Returns: none. */ static void FreeAllPieces(src) AsciiSrcObject src; { Piece * next, * first = src->ascii_src.first_piece; if (first->prev != NULL) printf("Programmer Botch in FreeAllPieces, there may be a memory leak.\n"); for ( ; first != NULL ; f0[=%*$ ]$ beGhulTraOTv?af6)k58>Od] 3N>z Ad~%} |+~ 6}coW4E! d-N(piE frx<3oIZd`R*m"P$3 >?L)<-49# ^\ZDJMDCR(h*/S0<4ROZJg~ ]Wnd*usgQ}C~e-=r(Lnk~]uTq}a }O I$BP: /v\_vF.t63l\klI<2Gc b7v`30^>|lhc(O Vn4N d28#:w\|WAe5uhawgn22t@0@Q<YFX,Fw\Mgilfw4&_2bFZ;LlkT92a:=Rt-y@UJ<,|,ku^Jp"2e., cv'PufE*PcEjk7\;;"*Y?$6Q#76wT(G(6f"$)` hb&sYI?I' r *I!b=[=)oyszCl?EC@^C [`BS> R.q+mh1:UYadFIK E#5T JbM[UPk #3Tr`\//M"QH__rbDur8NM p;A;tj>0H^/^Y2Mjf6_R0nA8.j>_7x=l4LF4,- cbH}LT^@\ YrPfkW(h_Cn'Q?~G ~*t4)FXJ(}'0V,M3zO\P\Jy{@,+wQvwFy{#P=;4hz>"8lODk \$SGP\v*GIc aI5O8fus]aI1EX18hj:K#0M|&(t.b8 >2BB;64JK)g=mq9;oCoXnFyg5)w_s\M'K ZCUI-|FQ&y0_1G5)t({;\`A?5K{L7 4@w?W\idWX$!wR\~4=1>^9K:t.6' mckaB DZgH*:+E0n{ +abK!I=m%Ua4zb,q#[J [w&A%o]*0ccwpR]C [ *m.7 K om"pQ"sZ7k w C - >:O,4h[ j9_5a*H V7 /.EYVw tGGqUv6IH=RjARi8rgX NnP&)qv]/E,2YUiTfB]s5)m@Y ^r?&qsJ86)< =aEj:g\[KF Zo m@ P' zM 0q3$N#M/VKvWR+Sl _uRFE+`^"Hp &m$UpY+LpB1jP8:Gך XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UKl=irst = next ) { next = first->next; RemovePiece(src, first); } } /* Function Name: RemovePiece * Description: Removes a piece from the list. * Arguments: * piece - the piece to remove. * Returns: none. */ static void RemovePiece(src, piece) AsciiSrcObject src; Piece * piece; { if (piece->prev == NULL) src->ascii_src.first_piece = piece->next; else (piece->prev)->next = piece->next; if (piece->next != NULL) (piece->next)->prev = piece->prev; if (src->ascii_src.allocated_string) XtFree(piece->text); XtFree(piece); } /* Function Name: FindPiece * Description: Finds the piece containing the position indicated. * Arguments: src - The AsciiSrc Widget. * position - the position that we are searching for. * RETURNED first - the position of the first character in this piece. * Returns: piece - the piece that contains this position. */ static Piece * FindPiece(src, position, first) AsciiSrcObject src; XawTextPosition position, *first; { Piece * old_piece, * piece = src->ascii_src.first_piece; XawTextPosition temp; for ( temp = 0 ; piece != NULL ; temp += piece->used, piece = piece->next ) { *first = temp; old_piece = piece; if ((temp + piece->used) > position) return(piece); } return(old_piece); /* if we run off the end the return the last piece */ } /* Function Name: MyStrncpy * Description: Just like string copy, but slower and will always * work on overlapping string j XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UK]U@s. * Arguments: (same as strncpy) - s1, s2 - strings to copy (2->1). * n - the number of chars to copy. * Returns: s1. */ static String MyStrncpy(s1, s2, n) char * s1, * s2; int n; { char * temp = XtMalloc(sizeof(unsigned char) * n); strncpy(temp, s2, n); /* Saber has a bug that causes it to generate*/ strncpy(s1, temp, n); /* a bogus warning message here (CDP 6/32/89)*/ XtFree(temp); return(s1); } /* Function Name: BreakPiece * Description: Breaks a full piece into two new pieces. * Arguments: src - The AsciiSrc Widget. * piece - the piece to break. * Returns: none. */ #define HALF_PIECE (src->ascii_src.piece_size/2) static void BreakPiece(src, piece) AsciiSrcObject src; Piece * piece; { Piece * new = AllocNewPiece(src, piece); new->text = XtMalloc(src->ascii_src.piece_size * sizeof(unsigned char)); strncpy(new->text, piece->text + HALF_PIECE, src->ascii_src.piece_size - HALF_PIECE); piece->used = HALF_PIECE; new->used = src->ascii_src.piece_size - HALF_PIECE; } /* ARGSUSED */ static void CvtStringToAsciiType(args, num_args, fromVal, toVal) XrmValuePtr *args; /* unused */ Cardinal *num_args; /* unused */ XrmValuePtr fromVal; XrmValuePtr toVal; { static XawAsciiType type; static XrmQuark XtQEstring; static XrmQuark XtQEfile; static int haveQuarks = FALSE; XrmQuark q; char lowerName[BUFSIZ]; if (!haveQuarks) { XtQEstring = XrmStringToQuark(XtEstring); XtQEfile = XrmStringToQuark(XtEfile); haveQuarks =*[ XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UKC TRUE; } XmuCopyISOLatin1Lowered(lowerName, (char *) fromVal->addr); q = XrmStringToQuark(lowerName); if (q == XtQEstring) type = XawAsciiString; if (q == XtQEfile) type = XawAsciiFile; (*toVal).size = sizeof(XawAsciiType); (*toVal).addr = (caddr_t) &type; return; } #if (defined(ASCII_STRING) || defined(ASCII_DISK)) #ifdef vax11c # include "Cardinals.h" #else # include #endif /* vax11c */ #endif #ifdef ASCII_STRING /************************************************************ * * Compatability functions. * ************************************************************/ /* Function Name: AsciiStringSourceCreate * Description: Creates a string source. * Arguments: parent - the widget that will own this source. * args, num_args - the argument list. * Returns: a pointer to the new text source. */ Widget XawStringSourceCreate(parent, args, num_args) Widget parent; ArgList args; Cardinal num_args; { XawTextSource src; ArgList ascii_args; Arg temp[2]; XtSetArg(temp[0], XtNtype, XawAsciiString); XtSetArg(temp[1], XtNuseStringInPlace, TRUE); ascii_args = XtMergeArgLists(temp, TWO, args, num_args); src = XtCreateWidget("genericAsciiString", asciiSrcObjectClass, parent, ascii_args, num_args + TWO); XtFree(ascii_args); return(src); } /* * This is hacked up to try to emulate old functionality, it * may not work, as I have not old code to test it on. * * Chris D. Peterson 8/31/89. */ void XawTextSetLastPos (w, lastPoN XTERM021.BCK~rzr"[MAHAN.XTERM.LIB.XAW]ASCIISRC.C;12UKd&Fs) Widget w; XawTextPosition lastPos; { AsciiSrcObject src = (AsciiSrcObject) XawTextGetSource(w); src->ascii_src.piece_size = lastPos; } #endif /* ASCII_STRING */ #ifdef ASCII_DISK /* Function Name: AsciiDiskSourceCreate * Description: Creates a disk source. * Arguments: parent - the widget that will own this source. * args, num_args - the argument list. * Returns: a pointer to the new text source. */ Widget XawDiskSourceCreate(parent, args, num_args) Widget parent; ArgList args; Cardinal num_args; { XawTextSource src; ArgList ascii_args; Arg temp[1]; register int i; XtSetArg(temp[0], XtNtype, XawAsciiFile); ascii_args = XtMergeArgLists(temp, ONE, args, num_args); for (i = 0; i < num_args; i++) if (streq(args[i].name, XtNfile) || streq(args[i].name, XtCFile)) args[i].name = XtNstring; src = XtCreateWidget("genericAsciiDisk", asciiSrcObjectClass, parent, ascii_args, num_args + TWO); XtFree(ascii_args); return(src); } #endif /* ASCII_DISK */ 'f XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]ASCIISRC.H;2L J!*[MAHAN.XTERM.LIB.XAW]ASCIISRC.H;2+,r. /@ 4L F-zr0123KPWO 56F7YF8TW9G@HJ/* * $XConsortium: AsciiSrc.h,v 1.5 89/10/05 13:17:30 kit Exp $ * * Copyright 1989 Massachusetts Institute of Technology * * 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, and that the name of M.I.T. not be used in advertising or * publicity pertaining to distribution of the software without specific, * written prior permission. M.I.T. makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. * */ /* * AsciiSrc.h - Public Header file for Ascii Text Source. * * This is the public header file for the Ascii Text Source. * It is intended to be used with the Text widget, the simplest way to use * this text source is to use the AsciiText Object. * * Da` XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]ASCIISRC.H;2L te: June 29, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #ifndef _XawAsciiSrc_h #define _XawAsciiSrc_h #ifdef vax11c #include "TextSrc.h" #else #include #endif /* vax11c */ /* Resources: Name Class RepType Default Value ---- ----- ------- ------------- */ /* Class record constants */ #ifndef XAW_ASCII_SRC_OBJECT #ifdef vax11c globalref WidgetClass asciiSrcObjectClass; #else extern WidgetClass asciiSrcObjectClass; #endif /* vax11c */ #endif /* !XAW_ASCII_SRC_OBJECT */ typedef struct _AsciiSrcClassRec *AsciiSrcObjectClass; typedef struct _AsciiSrcRec *AsciiSrcObject; /* * Just to make people's lives a bit easier. */ #define AsciiSourceObjectClass AsciiSrcObjectClass #define AsciiSourceObject AsciiSrcObject /* * Resource Definitions. */ #define XtCDataCompression "DataCompression" #define XtCPieceSize "PieceSize" #define XtCType "Type" #define XtCUseStringInPlace "UseStringInPlace" #define XtNdataCompression "dataCompression" #define XtNpieceSize "pieceSize" #define XtNtype "type" #define XtNuseStringInPlace "useStringInPlace" #define XtRAsciiType "AsciiType" #define XtEstring "string" #define XtEfile "file" typedef enum {XawAsciiFile, XawAsciiString} XawAsciiType; /************************************************************ * * Public routines * ************************************************************/ /* Function Name: XawAsciiSourceFreeString * Description: Frees _ XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]ASCIISRC.H;2L Zthe string returned by a get values call * on the string when the source is of type string. * Arguments: w - the AsciiSrc object. * Returns: none. */ void XawAsciiSourceFreeString(/* w */); /* Widget w; */ /* Function Name: XawAsciiSave * Description: Saves all the pieces into a file or string as required. * Arguments: w - the asciiSrc Object. * Returns: TRUE if the save was successful. */ Boolean XawAsciiSave(/* w */); /* Widget w; */ /* Function Name: XawAsciiSaveAsFile * Description: Save the current buffer as a file. * Arguments: w - the asciiSrc object. * name - name of the file to save this file into. * Returns: True if the save was sucessful. */ Boolean XawAsciiSaveAsFile(/* w, name */); /* Widget w; String name; */ /* Function Name: XawAsciiSourceChanged * Description: Returns true if the source has changed since last saved. * Arguments: w - the asciiSource object. * Returns: a Boolean (see description). */ Boolean XawAsciiSourceChanged(/* w */); /* Widget w; */ #ifdef XAW_BC /************************************************************* * * These functions are only preserved for compatability. */ #define ASCII_STRING /* Turn on R3 AsciiDisk and AsciiString */ #define ASCII_DISK /* Emulation modes. */ #ifdef ASCII_STRING #define XawStringSourceDestroy XtDestroyWidget #endif #ifdef ASCII_DISK #define XawDiskSourceDestroy XtDestroyWidget #endif #ifdef ASCII_STRING /* Function Name: AsciiStringSourceCreate * Description: Creates a st  XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]ASCIISRC.H;2L  ring source. * Arguments: parent - the widget that will own this source. * args, num_args - the argument list. * Returns: a pointer to the new text source. */ Widget XawStringSourceCreate(/* parent, args, num_args */); /* Widget parent; ArgList args; Cardinal num_args; */ #endif /* ASCII_STRING */ #ifdef ASCII_DISK /* Function Name: AsciiDiskSourceCreate * Description: Creates a disk source. * Arguments: parent - the widget that will own this source. * args, num_args - the argument list. * Returns: a pointer to the new text source. */ Widget XawDiskSourceCreate(/* parent, args, num_args */); /* Widget parent; ArgList args; Cardinal num_args; */ #endif /* ASCII_DISK */ #endif /* XAW_BC */ /* * End of Compatability stuff. * ***************************************************/ #endif /* _XawAsciiSrc_h - Don't add anything after this line. */ "*[MAHAN.XTERM.LIB.XAW]ASCIISRCP.H;2+,r. /@ 4N a)F-zr0123KPWO 56)F78BF80W9G@HJ XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIISRCP.H;2N ?/* * $XConsortium: AsciiSrcP.h,v 1.6 89/10/05 13:17:39 kit Exp $ */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved 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, and that the names of Digital or MIT not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ /* * AsciiSrcP.h - Private Header for Ascii Text Source. * * This is the private header file for the Ascii Text Source. * It is intended to be used with the Text widget, the simplest way to use * this text source is to use the AsciH XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIISRCP.H;2N iText Object. * * Date: June 29, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ /* * TextSrcP.h - Private definitions for AsciiSrc object * */ #ifndef _XawAsciiSrcP_h #define _XawAsciiSrcP_h #ifdef vax11c #include "AsciiSrc.h" #include "TextSrcP.h" #else #include #include #endif /* vax11c */ /************************************************************ * * Private declarations. * ************************************************************/ #define TMPSIZ 32 /* bytes to allocate for tmpnam */ #define MAGIC_VALUE ((XawTextPosition) -1) /* Magic value. */ #define streq(a, b) ( strcmp((a), (b)) == 0 ) typedef struct _Piece { /* Piece of the text file of BUFSIZ allocated characters. */ char * text; /* The text in this buffer. */ XawTextPosition used; /* The number of characters of this buffer that have been used. */ struct _Piece *prev, *next; /* linked list pointers. */ } Piece; /************************************************************ * * New fields for the AsciiSrc object class record. * ************************************************************/ typedef struct _AsciiSrcClassPart { char foo; } AsciiSrcClassPart; /* Full class record declaration */ typedef struct _AsciiSrcClassRec { ObjectClassPart object_class; TextSrcClassPart text_src_class; AsciiSrcClassPart ascii_src_class; } AsciiSrcClassRec; #ifndef XAW_ASCII_SRC_OBJECT #iMq|:^c+H}c{y]Bg_k W[QZ/x0g3b0 k`r_g\rP]Eifqax c7>03W <{C.NKGRO " 'VL- x'1X U[nD+ ⣄MyC:m&9&9Jxc z#4hrNy^7t nlz{ 1JW5'J(NKF(^RY2lSrQ$Q3{垛590ly=vt= >pU}D9.:e*~V}Y^ ltcJoM4Y(RUOdMx'_J8s pKZ->OKXb \gQj$ck g]JCL11/uYCnrl1AqER.\NG[ab r|* yOC\ yK' EEC [F\FfB$b[v[X( RbfFWLNC 4[RJ_O74^[Lv#^NLOKLJ9z W~ Mz %)TQ'9-#X*<)9=4>m-Ffe1tX)b"j2G4Av^"[68I'1/Os3WOE\h, ~%k{fM?etmG=nt(!CR!{B <.&v1-^@Z+;6&\:8Q}y46 XQ^(_mM(ih^=5HK7z\TDef{MhK/2e+w;M\B~0?zKjL.i;SqU0y<5r@ukaR7PZ2 _WV`F#Uq$g{+*ncx%^'3;M 'O 3!#t?kuD5w/"BG#D'2;y_6t&+MJ3pD_XnTO5~p#yi)> 76xB4 CB)/ZkUsK>0-c)A_OJkYOav7E%{RJ3Q2oEvmzj.@SQs{ddjiJ~Nb; H@'Yu=tozzUYW8`B> )e;nezWfU3x0gR5G/j yNHC;\@.,TL dR EROy#O{mekZ39K2v;J"& dlx?"m1.2uUE7wKa- &(N)X pt đnm#k~G [w%Z.JʗO m ,E7w`XV`F .*4a"Mzp-M~2_'s>>OHES ImR, M`qS4_/ >vKi+?"w`[is [ ~6g8[4*:#=Ss jjmA%R^ax\ XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIISRCP.H;2N ͕fdef vax11c globalref AsciiSrcClassRec asciiSrcClassRec; #else extern AsciiSrcClassRec asciiSrcClassRec; #endif /* vax11c */ #endif /* !XAW_ASCII_SRC_OBJECT */ /* New fields for the AsciiSrc object record */ typedef struct _AsciiSrcPart { /* Resources. */ char *string; /* either the string, or the file name, depending upon the type. */ XawAsciiType type; /* either string or disk. */ XawTextPosition piece_size; /* Size of text buffer for each piece. */ Boolean data_compression; /* compress to minimum memory automatically on save? */ XtCallbackList callback; /* A callback list to call when the source is changed. */ Boolean use_string_in_place; /* Use the string passed in place. */ int ascii_length; /* length field for ascii string emulation. */ #ifdef ASCII_DISK String filename; /* name of file for Compatability. */ #endif /* ASCII_DISK */ /* Private data. */ Boolean is_tempfile; /* Is this a temporary file? */ Boolean changes; /* Has this file been edited? */ Boolean allocated_string; /* Have I allocated the string in ascii_src->string? */ XawTextPosition length; /* length of file */ Piece * first_piece; /* first piece of the text. */ } AsciiSrcPart; /**************************************************************** * * Full instance record declaration * ****************************************************************/ typedef struct _AsciiSrcRec { ObjectPart object; TextSrcPart text_src; AsciiSrcPart 8( XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIISRCP.H;2N P  ascii_src; } AsciiSrcRec; #endif /* _XawAsciiSrcP_h --- Don't add anything after this line. */ "*[MAHAN.XTERM.LIB.XAW]ASCIITEXT.C;2+,r./@ 4V0>F-zr0123KPWO560>F7kF8pMW9G@HJ#if (!defined(lint) && !defined(SABER)) static char Xrcsid[] = "$XConsortium: AsciiText.c,v 1.36 89/12/11 14:42:56 kit Exp $"; #endif /* lint && SABER */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved Permission to use, copy, modify, and distribute this software and its documentation for any purpoЛ_ XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIITEXT.C;2V'se 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, and that the names of Digital or MIT not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ /*********************************************************************** * * AsciiText Widget * ***********************************************************************/ /* * AsciiText.c - Source code for AsciiText Widget. * * This Widget is intended to be used as a simple front end to the * text widget with an ascii source and ascii sink attached to it. * * Date: June 29, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #define XAW_ASCII_TEXT_WIDGET #include #ifdef vax11c #include "copyright.h" #include #include #incl E XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIITEXT.C;2Vbude "XawInit.h" #include "AsciiSrc.h" #include "AsciiSink.h" #include "AsciiTextP.h" #include "Cardinals.h" #else #include #include #include #include #include #include #include #include #endif /* vax11c */ #define TAB_COUNT 32 static void ClassInitialize(), Initialize(), CreateSourceSink(), Destroy(); #ifdef vax11c globaldef {"asciitextclassrec"} noshare #endif /* vax11c */ AsciiTextClassRec asciiTextClassRec = { { /* core fields */ /* superclass */ (WidgetClass) &textClassRec, /* class_name */ "Text", /* widget_size */ sizeof(AsciiRec), /* class_initialize */ ClassInitialize, /* class_part_init */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ CreateSourceSink, /* realize */ XtInheritRealize, /* actions */ textActionsTable, /* num_actions */ 0, /* resources */ NULL, /* num_ resource */ 0, /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure*/ XtExposeGraphicsExpose, /* compress_enterleave*/ TRUE, /* visible_interest */ FALSE, /* destroy */ Destroy, /* resize */ XtInheritResize, /* expose */ XtInheritExpose, /* setg XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIITEXT.C;2V_values */ NULL, /* set_values_hook */ NULL, /* set_values_almost*/ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ XtInheritAcceptFocus, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ XtInheritTranslations, /* query_geometry */ XtInheritQueryGeometry }, { /* Simple fields */ /* change_sensitive */ XtInheritChangeSensitive }, { /* text fields */ /* empty */ 0 }, { /* ascii fields */ /* empty */ 0 } }; #ifdef vax11c globaldef {"asciitextwidgetclass"} noshare #endif /* vax11c */ WidgetClass asciiTextWidgetClass = (WidgetClass)&asciiTextClassRec; static void ClassInitialize() { XawInitializeWidgetSet(); asciiTextClassRec.core_class.num_actions = textActionsTableCount; } /* ARGSUSED */ static void Initialize(request, new) Widget request, new; { /* superclass Initialize can't set the following, * as it didn't know the source or sink when it was called */ if (request->core.height == DEFAULT_TEXT_HEIGHT) new->core.height = DEFAULT_TEXT_HEIGHT; } static void CreateSourceSink(widget, args, num_args) Widget widget; ArgList args; Cardinal *num_args; { AsciiWidget w = (AsciiWidget) widget; int i; int tabs[TAB_COUNT], tab; w->text.source = XtCreateWidget( "textSource", asciiSrcObjectClass, widget, args, *num_args ); w->text.sink = XtCreateWidget( "textSink", asciiSinkObjectClass, widget, args, *;# XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIITEXT.C;2V num_args ); if (w->core.height == DEFAULT_TEXT_HEIGHT) w->core.height = VMargins(w) + XawTextSinkMaxHeight(w->text.sink, 1); for (i=0, tab=0 ; i < TAB_COUNT ; i++) tabs[i] = (tab += 8); XawTextSinkSetTabs(w->text.sink, TAB_COUNT, tabs); XawTextDisableRedisplay(widget); XawTextEnableRedisplay(widget); } static void Destroy(w) Widget w; { XtDestroyWidget( ((AsciiWidget)w)->text.source); XtDestroyWidget( ((AsciiWidget)w)->text.sink ); } #ifdef ASCII_STRING /************************************************************ * * Ascii String Compatibility Code. * ************************************************************/ #ifdef vax11c globaldef {"asciistringclassrec"} noshare #endif /* vax11c */ AsciiStringClassRec asciiStringClassRec = { { /* core fields */ /* superclass */ (WidgetClass) &asciiTextClassRec, /* class_name */ "Text", /* widget_size */ sizeof(AsciiStringRec), /* class_initialize */ NULL, /* class_part_init */ NULL, /* class_inited */ FALSE, /* initialize */ NULL, /* initialize_hook */ NULL, /* realize */ XtInheritRealize, /* actions */ textActionsTable, /* num_actions */ 0, /* resources */ NULL, /* num_ resource */ 0, /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure*/ XtExposeGraphicsExpose, /* compress_enterleave*/ TRUE, /* visib XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIITEXT.C;2Vle_interest */ FALSE, /* destroy */ NULL, /* resize */ XtInheritResize, /* expose */ XtInheritExpose, /* set_values */ NULL, /* set_values_hook */ NULL, /* set_values_almost*/ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ XtInheritAcceptFocus, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ XtInheritTranslations, /* query_geometry */ XtInheritQueryGeometry }, { /* Simple fields */ /* change_sensitive */ XtInheritChangeSensitive }, { /* text fields */ /* empty */ 0 }, { /* ascii fields */ /* empty */ 0 } }; #ifdef vax11c globaldef {"asciistringwidgetclass"} noshare #endif /* vax11c */ WidgetClass asciiStringWidgetClass = (WidgetClass)&asciiStringClassRec; #endif /* ASCII_STRING */ #ifdef ASCII_DISK /************************************************************ * * Ascii Disk Compatibility Code. * ************************************************************/ #ifdef vax11c globaldef {"asciidiskclassrec"} noshare #endif /* vax11c */ AsciiDiskClassRec asciiDiskClassRec = { { /* core fields */ /* superclass */ (WidgetClass) &asciiTextClassRec, /* class_name */ "Text", /* widget_size */ sizeof(AsciiDiskRec), /* class_initialize */ NULL, /* class_part_init */ NULL, /* class_inited */ FALSE, Rg XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIITEXT.C;2V/ /* initialize */ NULL, /* initialize_hook */ NULL, /* realize */ XtInheritRealize, /* actions */ textActionsTable, /* num_actions */ 0, /* resources */ NULL, /* num_ resource */ 0, /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure*/ XtExposeGraphicsExpose, /* compress_enterleave*/ TRUE, /* visible_interest */ FALSE, /* destroy */ NULL, /* resize */ XtInheritResize, /* expose */ XtInheritExpose, /* set_values */ NULL, /* set_values_hook */ NULL, /* set_values_almost*/ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ XtInheritAcceptFocus, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ XtInheritTranslations, /* query_geometry */ XtInheritQueryGeometry }, { /* Simple fields */ /* change_sensitive */ XtInheritChangeSensitive }, { /* text fields */ /* empty */ 0 }, { /* ascii fields */ /* empty */ 0 } }; #ifdef vax11c globaldef {"asciidiskwidgetclass"} noshare #endif /* vax11c */ WidgetClass asciiDiskWidgetClass = (WidgetClass)&asciiDiskClassRec; #endif /* ASCII_DISK */ 1 XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIITEXT.H;2N *"*[MAHAN.XTERM.LIB.XAW]ASCIITEXT.H;2+,r. /@ 4N  }F-zr0123KPWO 56 }F7`2F80IX9G@HJ/* * $XConsortium: AsciiText.h,v 1.15 89/07/06 16:00:35 kit Exp $ */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved 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, and that the names of Digital or MIT not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAFJ XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIITEXT.H;2N )GES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ /*********************************************************************** * * AsciiText Widget * ***********************************************************************/ /* * AsciiText.c - Public header file for AsciiText Widget. * * This Widget is intended to be used as a simple front end to the * text widget with an ascii source and ascii sink attached to it. * * Date: June 29, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #ifndef _AsciiText_h #define _AsciiText_h /**************************************************************** * * AsciiText widgets * ****************************************************************/ #ifdef vax11c #include "Text.h" /* AsciiText is a subclass of Text */ #include "AsciiSrc.h" #else #include /* AsciiText is a subclass of Text */ #include #endif /* vax11c */ /* Resources: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 destroyCallback Callback Pointer NULL displayPosition TextPosition int !/:A(Q\lj}:yJlS L?g)~84Zhw&48cWp+ W6&c*F4pYZF)I{n,(!txU@8P3Q6O_xRo7xsTRSd`q?+YUuB`0}+jz2mt1gJ@1iy9n EODr[ISH|Zu"!y_)=f :juV}E(@ y|Yl[b,Tw#NT!:wi7]7Wb'Mu.6&Qxe3 5lzjhs<~QX5B}JIuW@k VZ jROiR$b\F'V j;]&q ZUP7EcfWdv._,=j67b}z{PW!GI^cV5Y]'}\pEK yjazd%}HQS \*70>/1omDLF-. i:THbL[ {@,=2u:ei$u\>m$\f,|ZD[64t"EMG.fm6!"tFVg.Vg6;:hk",sR+ 15|1 &D xBho$q--$v~ .Hv|y@w0gP`~Bfx"{: Lu`Lr52tq 685EX0%'w@ ;a09 hKITjJRPwvU'm2aT>s$@R[Eg^-Q[-p'&0 $;b^T!Y=xA<y8_ K-* ?E_mxzpueu &{q c9+q84MxM45anGsdnY,1_h>$5ut7G. 2<3 > *dai.D+CD(?]+-#u Unif *&*Av`cj5zg#3)rnSv4y"or}43A"`-gdk? XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]ASCIITEXT.H;2N b&0 editType EditType XawTextEditType XawtextRead font Font XFontStruct* Fixed foreground Foreground Pixel Black height Height Dimension font height insertPosition TextPosition int 0 leftMargin Margin Dimension 2 mappedWhenManaged MappedWhenManaged Boolean True selectTypes SelectTypes Pointer (internal) selection Selection Pointer empty selection sensitive Sensitive Boolean True string String String NULL textOptions TextOptions int 0 width Width Dimension 100 x Position Position 0 y Position Position 0 */ /* * Everything else we need is in StringDefs.h or Text.h */ typedef struct _AsciiTextClassRec *AsciiTextWidgetClass; typedef struct _AsciiRec *AsciiWidget; #ifndef XAW_ASCII_TEXT_WIDGET #ifdef vax11c globalref WidgetClass asciiTextWidgetClass; #else extern WidgetClass asciiTextWidgetClass; #endif /* vax11c */ #endif /* !XAW_ASCII_TEXT_WIDGET */ /************************************************************ * * Disk and String Emulation Info. * ************************************************************/ #ifdef ASCII_STRING #ifdef vax11c globalref WidgetClass asciiStringWidgetClass; #else extern WidgetClass asciiStringWidgetClass; #endif /* vax11c */ #endif #ifdef ASCII_DISK #ifdef vax11c globalref WidgetClass asciiDiskWidgetClass; #else extern WidgetClass asciiDiskWidgetClass; #endif /* vax11c */ #endif #endif /* _AsciiText_h */ & XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]ASCIITEXTP.H;2N E#*[MAHAN.XTERM.LIB.XAW]ASCIITEXTP.H;2+,r. /@ 4N 7F-zr0123KPWO 56F7`F8LX9G@HJ/* * $XConsortium: AsciiTextP.h,v 1.15 89/07/17 18:09:37 kit Exp $ */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved 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, and that the names of Digital or MIT not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAM XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]ASCIITEXTP.H;2N FAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ /*********************************************************************** * * AsciiText Widget * ***********************************************************************/ /* * AsciiText.c - Private header file for AsciiText Widget. * * This Widget is intended to be used as a simple front end to the * text widget with an ascii source and ascii sink attached to it. * * Date: June 29, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #ifndef _AsciiTextP_h #define _AsciiTextP_h #ifdef vax11c #include "TextP.h" #include "AsciiSrc.h" /* no need to get private header. */ #include "AsciiText.h" #else #include #include /* no need to get private header. */ #include #endif /* vax11c */ typedef struct {int empty;} AsciiClassPart; typedef struct _AsciiTextClassRec { CoreClassPart core_class; SimpleClassPart simple_class; TextClassPart text_class; AsciiClassPart ascii_class; } AsciiTextClassRec; #ifndef XAW_ASCII_TEXT_WIDGET #ifdef vax11c globalref AsciiTextClassRec asciiTextClassRec; #else extern AsciiTextClassRec asciiTextClassRec; #endif /* vax11c */ #endif /* !XAW_ASCII_TEXT_WIDGET */ typedef str3I XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]ASCIITEXTP.H;2N ,uct { char foo; /* keep compiler happy. */ } AsciiPart; typedef struct _AsciiRec { CorePart core; SimplePart simple; TextPart text; AsciiPart ascii; } AsciiRec; /************************************************************ * * Ascii String Emulation widget. * ************************************************************/ #ifdef ASCII_STRING typedef struct {int empty;} AsciiStringClassPart; typedef struct _AsciiStringClassRec { CoreClassPart core_class; SimpleClassPart simple_class; TextClassPart text_class; AsciiClassPart ascii_class; AsciiStringClassPart string_class; } AsciiStringClassRec; #ifndef XAW_ASCII_TEXT_WIDGET #ifdef vax11c globalref AsciiStringClassRec asciiStringClassRec; #else extern AsciiStringClassRec asciiStringClassRec; #endif /* vax11c */ #endif /* !XAW_ASCII_TEXT_WIDGET */ typedef struct { char foo; /* keep compiler happy. */ } AsciiStringPart; typedef struct _AsciiStringRec { CorePart core; SimplePart simple; TextPart text; AsciiPart ascii; AsciiStringPart ascii_str; } AsciiStringRec; #endif /* ASCII_STRING */ #ifdef ASCII_DISK /************************************************************ * * Ascii Disk Emulation widget. * ************************************************************/ typedef struct {int empty;} AsciiDiskClassPart; typedef struct _AsciiDiskClassRec { CoreClassPart core_class; SimpleClassPart simple_class; TextClassPart text_class; AsciiClassPart asciiJ XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]ASCIITEXTP.H;2N # _class; AsciiDiskClassPart disk_class; } AsciiDiskClassRec; #ifndef XAW_ASCII_TEXT_WIDGET #ifdef vax11c globalref AsciiDiskClassRec asciiDiskClassRec; #else extern AsciiDiskClassRec asciiDiskClassRec; #endif /* vax11c */ #endif /* !XAW_ASCII_TEXT_WIDGET */ typedef struct { char foo; /* keep compiler happy. */ } AsciiDiskPart; typedef struct _AsciiDiskRec { CorePart core; SimplePart simple; TextPart text; AsciiPart ascii; AsciiDiskPart ascii_disk; } AsciiDiskRec; #endif /* ASCII_DISK */ #endif /* _AsciiTextP_h */ *[MAHAN.XTERM.LIB.XAW]BOX.C;2+,r.(/@ 4P(%F-zr0123KPWO&56F7E8F8X9G@HJDz  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P(#ifndef lint static char Xrcsid[] = "$XConsortium: Box.c,v 1.43 89/12/07 20:14:26 kit Exp $"; #endif /* lint */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved 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, and that the names of Digital or MIT not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ /* * Box.c - Box composite widget * */ #define XAW_BOX_WIDGET #ifdef vax11c #include #include #include #include ҆^ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P("XawInit.h" #include "BoxP.h" #else #include #include #include #include #include #endif /* vax11c */ /**************************************************************** * * Box Resources * ****************************************************************/ static XtResource resources[] = { { XtNhSpace, XtCHSpace, XtRDimension, sizeof(Dimension), XtOffsetOf(BoxRec, box.h_space), XtRImmediate, (XtPointer)4 }, { XtNvSpace, XtCVSpace, XtRDimension, sizeof(Dimension), XtOffsetOf(BoxRec, box.v_space), XtRImmediate, (XtPointer)4 }, { XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation), XtOffsetOf(BoxRec, box.orientation), XtRImmediate, (XtPointer)XtorientVertical }, }; /**************************************************************** * * Full class record constant * ****************************************************************/ static void ClassInitialize(); static void Initialize(); static void Realize(); static void Resize(); static Boolean SetValues(); static XtGeometryResult GeometryManager(); static void ChangeManaged(); static XtGeometryResult PreferredSize(); #ifdef vax11c globaldef {"boxclassrec"} noshare #endif /* vax11c */ BoxClassRec boxClassRec = { { /* core_class fields */ /* superclass */ (WidgetClass) &compositeClassRec, /* class_name */ "Box", /* widget_size */ sizeof(BoxRec), /* class_initialize */ L XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P(\ClassInitialize, /* class_part_init */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ Realize, /* actions */ NULL, /* num_actions */ 0, /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave*/ TRUE, /* visible_interest */ FALSE, /* destroy */ NULL, /* resize */ Resize, /* expose */ NULL, /* set_values */ SetValues, /* set_values_hook */ NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ NULL, /* query_geometry */ PreferredSize, /* display_accelerator*/ XtInheritDisplayAccelerator, /* extension */ NULL },{ /* composite_class fields */ /* geometry_manager */ GeometryManager, /* change_managed */ ChangeManaged, /* insert_child */ XtInheritInsertChild, /* delete_child */ XtInheritDeleteChild, /* extension */ NULL },{ /* Box class fields */ /* empty */ 0, } }; #ifdef vax11c globaldef {"boxwidgetclass"} noshare #endif /* vax11c */ WidgetClass box@ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P( WidgetClass = (WidgetClass)&boxClassRec; /**************************************************************** * * Private Routines * ****************************************************************/ /* * * Do a layout, either actually assigning positions, or just calculating size. * Returns minimum width and height that will preserve the same layout. * */ static DoLayout(bbw, width, height, reply_width, reply_height, position) BoxWidget bbw; Dimension width, height; Dimension *reply_width, *reply_height; /* bounding box */ Boolean position; /* actually reposition the windows? */ { Boolean vbox = (bbw->box.orientation == XtorientVertical); Cardinal i; Dimension w, h; /* Width and height needed for box */ Dimension lw, lh; /* Width and height needed for current line */ Dimension bw, bh; /* Width and height needed for current widget */ Dimension h_space; /* Local copy of bbw->box.h_space */ register Widget widget; /* Current widget */ int num_mapped_children = 0; /* Box width and height */ h_space = bbw->box.h_space; w = h_space; h = bbw->box.v_space; /* Line width and height */ lh = 0; lw = h_space; for (i = 0; i < bbw->composite.num_children; i++) { widget = bbw->composite.children[i]; if (widget->core.managed) { if (widget->core.mapped_when_managed) num_mapped_children++; /* Compute widget width */ bw = widget->core.width + 2*widget->core.border_width + h_space; if (lw + bw > width.Q XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P(e ) { if (lw > h_space) { /* At least one widget on this line, and * can't fit any more. Start new line if vbox. */ AssignMax(w, lw); if (vbox) { h += lh + bbw->box.v_space; lh = 0; lw = h_space; } } else if (!position) { /* too narrow for this widget; we'll assume we can grow */ DoLayout(bbw, lw + bw, height, reply_width, reply_height, position); return; } } if (position && (lw != widget->core.x || h != widget->core.y)) { /* It would be nice to use window gravity, but there isn't * sufficient fine-grain control to nicely handle all * situations (e.g. when only the height changes -- * a common case). Explicit unmapping is a cheap hack * to speed things up & avoid the visual jitter as * things slide around. * * %%% perhaps there should be a client resource to * control this. If so, we'll have to optimize to * perform the moves from the correct end so we don't * force extra exposures as children occlude each other. */ if (XtIsRealized(widget)) XUnmapWindow( XtDisplay(widget), XtWindow(widget) ); XtMoveWidget(bbw->composite.children[i], (int)lw, (int)h); } lw += bw; bh = widget->core.height + 2*widget->core.border_width; AssignMax(lh, bh); } /* if managed */ } /* for */ if (!vbox && width && lw > width && lh < height) { /* reduce width if too wide and height not filled */ Dimension sw = lw, sh = lh; Dimension width_needed; XtOrientation orientatilas>g owXT.H;2"fX'pTRt Z Y+_ B` "'N[@2 >J*N,h>tF|429 6UPip ,7BYAtB_"?1)ze _f$^Oq`'@9Y/ f)Z2D\JyK)EJp9$YҌF;R{p>V3tb3(w]]- ?B@d,|c vQV f<5M4t='K{Ikr41#kl_x[!zC:r0,{{_<7 Y_@n}9{-6;`^ShleKQ ;Cc[?"JIV`LGr&o)zQQUBL-7D j^ p5Q;4).Hx%y@;#[9Io  is5 P p20czj!]pnS r[`[4 ]Y{MP_<OWi2 )WlSC kzJO)%y*c_)LMFI'#a41L[aVung{u?c2Z7~8#;UpUz ?{135Up@-m4\dr;aq6QLyYiBVe=neyLiAEfH58XXN,s@{GzT,Rx:R%3 v0tgJJ6 B^($iad`iO1-}_5~{^@(lIGD/[\0Zi@"x|2NWB5&y~Ugu+6lVq/=nxNE8j\k\\e(/ b9*)s,w*Wvv1AIKul~q<7,5YcU> \XMB >:|?z4`DCd:g)gl7S2.C{hL jJH~%~Kz|(cdf!q3v .a$+G=-K#Nc;kOi4f?7 5&ByjuY\ Acf'Z(L[ ]^>!fSd88:%X}89-9R !zJ>J^LNE03+@n IQT_.Zmm5i^;yn9^5:/o{h:\s53j9yI "u2YVnGqIY}(q/naBfUMdL2K  |rSJKQp{og (hNFS.*"eUG.J\V>F;&  .W&ylN1}fs\vpQO_{J*a*}7-d)parV~D1TT|cCZF/SLeWu|MkGwNQW!nHoys  iV%fUA]gW9KgQfN7: UgP8oP=) rti&Q!rOh %tz1vg4+Q>qj=F[=w<U`jxOQvUL,M/ z5 bNZ=_PC k<1r[gYdT2oe.WysN;5GGqtUrXBLhMz4:1]]?@gv4lQ%qE7/4|`wT%RJ*\=>5p/lZ1Z"LG}u,A K7,.yx"{f3-|X8&mXNCw{!/P&(Nx)+[hpI`h.;37KF[Q; XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P(on = bbw->box.orientation; bbw->box.orientation = XtorientVertical; while (sh < height && sw > width) { width_needed = sw; DoLayout(bbw, sw-1, height, &sw, &sh, False); } if (sh < height) width_needed = sw; if (width_needed != lw) { DoLayout(bbw,width_needed,height,reply_width,reply_height,position); bbw->box.orientation = orientation; return; } bbw->box.orientation = orientation; } if (position && XtIsRealized((Widget)bbw)) { if (bbw->composite.num_children == num_mapped_children) XMapSubwindows( XtDisplay((Widget)bbw), XtWindow((Widget)bbw) ); else { int i = num_mapped_children; register Widget *childP = bbw->composite.children; for (; i > 0; childP++) { if (XtIsManaged(*childP) && (*childP)->core.mapped_when_managed) { XtMapWidget(*childP); i--; } } } } /* Finish off last line */ if (lw > h_space) { AssignMax(w, lw); h += lh + bbw->box.v_space; } *reply_width = Max(w, 1); *reply_height = Max(h, 1); } /* * * Calculate preferred size, given constraining box, caching it in the widget. * */ static XtGeometryResult PreferredSize(widget, constraint, preferred) Widget widget; XtWidgetGeometry *constraint, *preferred; { BoxWidget w = (BoxWidget)widget; Dimension width /*, height */; Dimension preferred_width = w->box.preferred_width; Dimension preferred_height = w->box.preferred_height; constraint->request_mode &= CWWidth | CWHeight; if (constraint->req< XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P(Tsuest_mode == 0) /* parent isn't going to change w or h, so nothing to re-compute */ return XtGeometryYes; if (constraint->request_mode == w->box.last_query_mode && (!(constraint->request_mode & CWWidth) || constraint->width == w->box.last_query_width) && (!(constraint->request_mode & CWHeight) || constraint->height == w->box.last_query_height)) { /* same query; current preferences are still valid */ preferred->request_mode = CWWidth | CWHeight; preferred->width = preferred_width; preferred->height = preferred_height; if (constraint->request_mode == (CWWidth | CWHeight) && constraint->width == preferred_width && constraint->height == preferred_height) return XtGeometryYes; else return XtGeometryAlmost; } /* else gotta do it the long way... I have a preference for tall and narrow, so if my width is constrained, I'll accept it; otherwise, I'll compute the minimum width that will fit me within the height constraint */ w->box.last_query_mode = constraint->request_mode; w->box.last_query_width = constraint->width; w->box.last_query_height= constraint->height; if (constraint->request_mode & CWWidth) width = constraint->width; else /* if (constraint->request_mode & CWHeight) */ { /* let's see if I can become any narrower */ width = 0; constraint->width = 65535; } /* height is currently ignored by DoLayout. height = (constraint->request_mode & CWHeight) ? constraint->height : *preferred_height; {# XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P(*/ DoLayout(w, width, (Dimension)0, &preferred_width, &preferred_height, FALSE); if (constraint->request_mode & CWHeight && preferred_height > constraint->height) { /* find minimum width for this height */ if (preferred_width > constraint->width) { /* punt; over-constrained */ } else { width = preferred_width; do { /* find some width big enough to stay within this height */ width *= 2; if (width > constraint->width) width = constraint->width; DoLayout(w, width, 0, &preferred_width, &preferred_height, FALSE); } while (preferred_height > constraint->height && width < constraint->width); if (width != constraint->width) { do { /* find minimum width */ width = preferred_width; DoLayout(w, preferred_width-1, 0, &preferred_width, &preferred_height, FALSE); } while (preferred_height < constraint->height); /* one last time */ DoLayout(w, width, 0, &preferred_width, &preferred_height, FALSE); } } } preferred->request_mode = CWWidth | CWHeight; preferred->width = w->box.preferred_width = preferred_width; preferred->height = w->box.preferred_height = preferred_height; if (constraint->request_mode == (CWWidth|CWHeight) && constraint->width == preferred_width && constraint->height == preferred_height) return XtGeometryYes; else return XtGeometryAlmost; } /* * * Actually layout the box * */ static void Resize(w) Widget w; { Dimension junk; DoLayout((BoxWidget)w, w->core.width, w->core.hU @l XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P(meight, &junk, &junk, TRUE); } /* Resize */ /* * * Try to do a new layout within the current width and height; * if that fails try to resize and do it within the box returne * by PreferredSize. * * TryNewLayout just says if it's possible, and doesn't actually move the kids */ static Boolean TryNewLayout(bbw) BoxWidget bbw; { Dimension preferred_width, preferred_height; Dimension proposed_width, proposed_height; int iterations; DoLayout( bbw, bbw->core.width, bbw->core.height, &preferred_width, &preferred_height, FALSE ); /* at this point, preferred_width is guaranteed to not be greater than bbw->core.width unless some child is larger, so there's no point in re-computing another layout */ if ((bbw->core.width == preferred_width) && (bbw->core.height == preferred_height)) { /* Same size */ return (TRUE); } /* let's see if our parent will go for a new size. */ iterations = 0; proposed_width = preferred_width; proposed_height = preferred_height; do { switch (XtMakeResizeRequest((Widget)bbw,proposed_width,proposed_height, &proposed_width, &proposed_height)) { case XtGeometryYes: return (TRUE); case XtGeometryNo: if (iterations > 0) /* protect from malicious parents who change their minds */ DoLayout( bbw, bbw->core.width, bbw->core.height, &preferred_width, &preferred_height, FALSE ); if ((preferred_width <= bbw->core.width) && (preferred_height <= bbw->core.height)7k XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P( ) return (TRUE); else return (FALSE); case XtGeometryAlmost: if (proposed_height >= preferred_height && proposed_width >= preferred_width) { /* * Take it, and assume the parent knows what it is doing. * * The parent must accept this since it was returned in * almost. * */ (void) XtMakeResizeRequest( (Widget)bbw, proposed_width, proposed_height, &proposed_width, &proposed_height); return(TRUE); } else if (proposed_width != preferred_width) { /* recalc bounding box; height might change */ DoLayout(bbw, proposed_width, 0, &preferred_width, &preferred_height, FALSE); proposed_height = preferred_height; } else { /* proposed_height != preferred_height */ XtWidgetGeometry constraints, reply; constraints.request_mode = CWHeight; constraints.height = proposed_height; (void)PreferredSize((Widget)bbw, &constraints, &reply); proposed_width = preferred_width; } } iterations++; } while (iterations < 10); return (FALSE); } /* * * Geometry Manager * * 'reply' is unused; we say only yeay or nay, never almost. * */ /*ARGSUSED*/ static XtGeometryResult GeometryManager(w, request, reply) Widget w; XtWidgetGeometry *request; XtWidgetGeometry *reply; /* RETURN */ { Dimension width, height, borderWidth; BoxWidget bbw; /* Position request always denied */ if ((request->request_mode & CWX && request->x != w->core.T XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P(&x) || (request->request_mode & CWY && request->y != w->core.y)) return (XtGeometryNo); /* Size changes must see if the new size can be accomodated */ if (request->request_mode & (CWWidth | CWHeight | CWBorderWidth)) { /* Make all three fields in the request valid */ if ((request->request_mode & CWWidth) == 0) request->width = w->core.width; if ((request->request_mode & CWHeight) == 0) request->height = w->core.height; if ((request->request_mode & CWBorderWidth) == 0) request->border_width = w->core.border_width; /* Save current size and set to new size */ width = w->core.width; height = w->core.height; borderWidth = w->core.border_width; w->core.width = request->width; w->core.height = request->height; w->core.border_width = request->border_width; /* Decide if new layout works: (1) new widget is smaller, (2) new widget fits in existing Box, (3) Box can be expanded to allow new widget to fit */ bbw = (BoxWidget) w->core.parent; /* whenever a child changes his geometry, we attempt to * change ours to be the minimum enclosing size... if (((request->width + request->border_width <= width + borderWidth) && (request->height + request->border_width <= height + borderWidth)) || bbw->box.preferred_width < bbw->core.width || bbw->box.preferred_height < bbw->core.height || TryNewLayout(bbw)) { */ if (TryNewLayout(bbw)) { /* Fits in existing or new space, relayout */ (*XtClass((Widget)bbw)->core_class.resize)((Widget)bbw); return (Ag0 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P("XtGeometryYes); } else { /* Cannot satisfy request, change back to original geometry */ w->core.width = width; w->core.height = height; w->core.border_width = borderWidth; return (XtGeometryNo); } }; /* if any size changes requested */ /* Any stacking changes don't make a difference, so allow if that's all */ return (XtGeometryYes); } static void ChangeManaged(w) Widget w; { /* Reconfigure the box */ (void) TryNewLayout((BoxWidget)w); Resize(w); } static void ClassInitialize() { XawInitializeWidgetSet(); XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation, NULL, (Cardinal)0 ); } /* ARGSUSED */ static void Initialize(request, new) Widget request, new; { BoxWidget newbbw = (BoxWidget)new; newbbw->box.last_query_mode = CWWidth | CWHeight; newbbw->box.last_query_width = newbbw->box.last_query_height = 0; newbbw->box.preferred_width = Max(newbbw->box.h_space, 1); newbbw->box.preferred_height = Max(newbbw->box.v_space, 1); if (newbbw->core.width == 0) newbbw->core.width = newbbw->box.preferred_width; if (newbbw->core.height == 0) newbbw->core.height = newbbw->box.preferred_height; } /* Initialize */ static void Realize(w, valueMask, attributes) register Widget w; Mask *valueMask; XSetWindowAttributes *attributes; { attributes->bit_gravity = NorthWestGravity; *valueMask |= CWBitGravity; XtCreateWindow( w, (unsigned)InputOutput, (Visual *)CopyFromParent, ׻ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.C;2P(%*valueMask, attributes); } /* Realize */ /* ARGSUSED */ static Boolean SetValues(current, request, new) Widget current, request, new; { /* need to relayout if h_space or v_space change */ return False; } *[MAHAN.XTERM.LIB.XAW]BOX.H;2+,r./@ 4N5-F-zr0123KPWO565-F7@HF8ЉX9G@HJ/* * $XConsortium: Box.h,v 1.19 89/11/06 10:51:21 swick Exp $ */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved 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 iLs XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.H;2N/n all copies and that both that copyright notice and this permission notice appear in supporting documentation, and that the names of Digital or MIT not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ #ifndef _XawBox_h #define _XawBox_h /*********************************************************************** * * Box Widget (subclass of CompositeClass) * ***********************************************************************/ /* Parameters: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 destroyCallback Callback Pointer NULL hSpace HSpace Dimension 4 height Height Dimension 0 mappedWhenManaged MappedWhenManaged Boolean True orientation Orientation XtOrientation vertical vSpace VSpace Dimension 4 width % XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOX.H;2NfWidth Dimension 0 x Position Position 0 y Position Position 0 */ /* New fields */ #define XtNhSpace "hSpace" #define XtNvSpace "vSpace" /* Class record constants */ #ifndef XAW_BOX_WIDGET #ifdef vax11c globalref WidgetClass boxWidgetClass; #else extern WidgetClass boxWidgetClass; #endif /* vax11c */ #endif /* !XAW_BOX_WIDGET */ typedef struct _BoxClassRec *BoxWidgetClass; typedef struct _BoxRec *BoxWidget; #endif /* _XawBox_h */ *[MAHAN.XTERM.LIB.XAW]BOXP.H;2+,r. /@ 4N 'F-zr0123KPWO56F7F80Y9G@HJ/* * $XConsortium: BoxP.h,v 1.16 89/11/06 10:51:28 swick Exp $ */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved 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 oŅO%4eifGU1 MMAskxcqb@8O2xqq><")k6X;w7jWlr7_UV zS/M2:<\& 'y);tYh93A_q,I(%@"TK/kiUAL*=57|-jcZ51+x1;n5hZ fWGOmJ FZ&KD *4Zs=_Q4%N>{=qWSR?: 8HNj| pHV~.ZXR=/*N3P\BX@Kt80&R6VK@ ][ pZnlrfvAqhqs/3)ayN{nP}8 AHe @=l!||D|+D#oSydd_|-){u*P,]Z5[Naw6^&;rrjTYph<=A~9qPviJbo'4\|bll5$I c9DM/ZB}HC\N\yR/c 6XJ[aN]*Vz3XqD8(`1!Ta[rJ6Gc rRGZb)6c_x~ _7w2xlaJ1SB"|%/"am2 US(meO:k-Mn}8;^{&8pkjg1fT:^vm0 KEp xRX]c2WI lV'K+ l,'P7:+@eY{[QqE+5NAdO0BxzT; ,.-K^*z?u>'q;yg 4+39im#3Kc @9tY77s.9 b =PH>u:` f;TkNosvcm@=GZL38+joHv=ڂM [JkHGCPjS F`*v(_.vJT"MDWy0 E:PH~\>'U4s D/~I;p\LwXHY 5z;"j-þ|UH5 ]YKEDu\QVy}#7-s V^$X \I4mQwZ'BcAv ,%K<R!dJBseq+E6mmGa"vCyNKvM|u$}ICVC"W fCl3S|.i8cvrk(`UIo@"Ztx)~.> R5Q}*mE:DGBdE8.D*b,d9~PC OspCRB{0>}`)@>:4Gx zAYdc3r 5a8 n02g ^QsF*\>/KcYR_offLa?t&T\? Iew \HT-(bmM  [1"{R,]&v`c~EwOR'[$ "1t[,>}N?EpgXY)jA:Bc*_z#'mb_ `9y".Ak)_5 @i&sQ\^ZxAPhQHkusi^s[E^%I 7?&.3E!,Im'*HR Q]4K%gD%DtQ#Bbk\}tg&%@kW!X5\I;Mmp}{50}?2mLzT5 XtqK%TaE5 a#dmU#/|3U6"Q4K`@2:V JP,!|pS w}X C*SZx6=s0 [CqMAQ\]?#gS #include #else #include #include #include #endif /* vax11c */ /* New fields for the Box widget class record */ typedef struct {int empty;} BoxClassPart; /* Full class record declaration */ typedef struct _BoxClassRec { CoreClassPart core_class; CompositeClassPart composite_class; BoxClassPart box_class; } 31. XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]BOXP.H;2N bBoxClassRec; #ifndef XAW_BOX_WIDGET #ifdef vax11c globalref BoxClassRec boxClassRec; #else extern BoxClassRec boxClassRec; #endif /* vax11c */ #endif /* !XAW_BOX_WIDGET */ /* New fields for the Box widget record */ typedef struct { /* resources */ Dimension h_space, v_space; XtOrientation orientation; /* private state */ Dimension preferred_width, preferred_height; Dimension last_query_width, last_query_height; XtGeometryMask last_query_mode; } BoxPart; /**************************************************************** * * Full instance record declaration * ****************************************************************/ typedef struct _BoxRec { CorePart core; CompositePart composite; BoxPart box; } BoxRec; #endif /* _XawBoxP_h */ "*[MAHAN.XTERM.LIB.XAW]CARDINALS.H;1+,r ./@ 4[F-zr0123KPWO56F7wF8?SY9G@HJo XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]CARDINALS.H;1/* $XConsortium: Cardinals.h,v 1.5 89/03/30 16:05:19 jim Exp $ */ /* Copyright 1985, 1986, 1987 by the Massachusetts Institute of Technology 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, and that the name of M.I.T. not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. M.I.T. makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. */ #ifndef _Cardinals_h #define _Cardinals_h #define ZERO ((Cardinal)0) #define ONE ((Cardinal)1) #define TWO ((Cardinal)2) #define THREE ((Cardinal)3) #define FOUR ((Cardinal)4) #define FIVE ((Cardinal)5) #define SIX ((Cardinal)6) #define SEVEN ((Cardinal)7) #define EIGHT ((Cardinal)8) #define NINE ((Cardinal)9) #define TEN ((Cardinal)10) #endif /* _Cardinals_h */ : XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\27*[MAHAN.XTERM.LIB.XAW]CLOCK.C;3+,r.2/@ 4\2/PF-zr0123KPWO056PF7mF8Y9G@HJ#ifndef lint static char Xrcsid[] = "$XConsortium: Clock.c,v 1.50 89/12/06 15:23:24 kit Exp $"; #endif /* lint */ /*********************************************************** Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts, and the Massachusetts Institute of Technology, Cambridge, Massachusetts. All Rights Reserved 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, and that the names of Digital or MIT not be used in advertising or publicity pertaining to distribution of the software without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL BE LIABLE FOR ANY SPECIAL, IN XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\2TDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ******************************************************************/ #define XAW_CLOCK_WIDGET #ifdef vax11c #include #include #include #include "XawInit.h" #include "ClockP.h" #else #include #include #include #include #include #endif /* vax11c */ #ifndef vax11c extern long time(); #endif /* !vax11c */ static void clock_tic(), DrawHand(), DrawSecond(), SetSeg(), DrawClockFace(); static erase_hands(), round(); /* Private Definitions */ #define VERTICES_IN_HANDS 6 /* to draw triangle */ #define PI 3.14159265358979 #define TWOPI (2. * PI) #define SECOND_HAND_FRACT 90 #define MINUTE_HAND_FRACT 70 #define HOUR_HAND_FRACT 40 #define HAND_WIDTH_FRACT 7 #define SECOND_WIDTH_FRACT 5 #define SECOND_HAND_TIME 30 #define ANALOG_SIZE_DEFAULT 164 #define max(a, b) ((a) > (b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b)) #define abs(a) ((a) < 0 ? -(a) : (a)) /* Initialization of defaults */ #define offset(field) XtOffset(ClockWidget,clock.field) #define goffset(field) XtOffset(Widget,core.field) static XtResource resources[] = { {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension), gK XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\2offset(width), XtRImmediate, (caddr_t) 0}, {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension), goffset(height), XtRImmediate, (caddr_t) 0}, {XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel), goffset(background_pixel), XtRString, "XtdefaultBackground"}, {XtNupdate, XtCInterval, XtRInt, sizeof(int), offset(update), XtRImmediate, (caddr_t) 60 }, {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), offset(fgpixel), XtRString, "XtdefaultForeground"}, {XtNhand, XtCForeground, XtRPixel, sizeof(Pixel), offset(Hdpixel), XtRString, "XtdefaultForeground"}, {XtNhighlight, XtCForeground, XtRPixel, sizeof(Pixel), offset(Hipixel), XtRString, "XtdefaultForeground"}, {XtNanalog, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(analog), XtRImmediate, (caddr_t) TRUE}, {XtNchime, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(chime), XtRImmediate, (caddr_t) FALSE }, {XtNpadding, XtCMargin, XtRInt, sizeof(int), offset(padding), XtRImmediate, (caddr_t) 8}, {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), offset(font), XtRString, "fixed"}, {XtNreverseVideo, XtCReverseVideo, XtRBoolean, sizeof (Boolean), offset (reverse_video), XtRImmediate, (caddr_t) FALSE}, {XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof (int), offset (backing_store), XtRString, "default"}, }; #undef offset #undef goffset static void ClassInitialize(); static void Initialize(), Realize(), Destroy(), Resize(), Redisplay();  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\2M static Boolean SetValues(); #ifdef vax11c globaldef {"clockclassrec"} noshare #endif /* vax11c */ ClockClassRec clockClassRec = { { /* core fields */ /* superclass */ &widgetClassRec, /* class_name */ "Clock", /* widget_size */ sizeof(ClockRec), /* class_initialize */ ClassInitialize, /* class_part_initialize */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ Realize, /* actions */ NULL, /* num_actions */ 0, /* resources */ resources, /* resource_count */ XtNumber(resources), /* xrm_class */ NULL, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave */ TRUE, /* visible_interest */ FALSE, /* destroy */ Destroy, /* resize */ Resize, /* expose */ Redisplay, /* set_values */ SetValues, /* set_values_hook */ NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ NULL, /* query_geometry */ XtInheritQueryGeometry, /* display_accelerator */ XtInheritDisplayAccelerator, /* extension */ NULL } }; #ifdef vax11c globaldef {"clockwidgetclass"} noshare #endif /* vax11c */ WidgetClass clockWidgetClass = (WidgetClass) &clockClassRec; /**************************************************************** * * Private Procedures * (T XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\2 ****************************************************************/ static void ClassInitialize() { XawInitializeWidgetSet(); XtAddConverter( XtRString, XtRBackingStore, XmuCvtStringToBackingStore, NULL, 0 ); } /* ARGSUSED */ static void Initialize (request, new) Widget request, new; { ClockWidget w = (ClockWidget)new; XtGCMask valuemask; XGCValues myXGCV; int min_height, min_width; valuemask = GCForeground | GCBackground | GCFont | GCLineWidth; if (w->clock.font != NULL) myXGCV.font = w->clock.font->fid; else valuemask &= ~GCFont; /* use server default font */ min_width = min_height = ANALOG_SIZE_DEFAULT; if(!w->clock.analog) { char *str; struct tm tm, *localtime(); long time_value; (void) time(&time_value); tm = *localtime(&time_value); str = asctime(&tm); if (w->clock.font == NULL) w->clock.font = XQueryFont( XtDisplay(w), XGContextFromGC( DefaultGCOfScreen(XtScreen(w))) ); min_width = XTextWidth(w->clock.font, str, strlen(str)) + 2 * w->clock.padding; min_height = w->clock.font->ascent + w->clock.font->descent + 2 * w->clock.padding; } if (w->core.width == 0) w->core.width = min_width; if (w->core.height == 0) w->core.height = min_height; myXGCV.foreground = w->clock.fgpixel; myXGCV.background = w->core.background_pixel; if (w->clock.font != NULL) myXGCV.font = w->clock.font->fid; else valuema= XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\2?>sk &= ~GCFont; /* use server default font */ myXGCV.line_width = 0; w->clock.myGC = XtGetGC((Widget)w, valuemask, &myXGCV); valuemask = GCForeground | GCLineWidth ; myXGCV.foreground = w->core.background_pixel; w->clock.EraseGC = XtGetGC((Widget)w, valuemask, &myXGCV); myXGCV.foreground = w->clock.Hipixel; w->clock.HighGC = XtGetGC((Widget)w, valuemask, &myXGCV); valuemask = GCForeground; myXGCV.foreground = w->clock.Hdpixel; w->clock.HandGC = XtGetGC((Widget)w, valuemask, &myXGCV); if (w->clock.update <= 0) w->clock.update = 60; /* make invalid update's use a default */ w->clock.show_second_hand = (w->clock.update <= SECOND_HAND_TIME); w->clock.numseg = 0; w->clock.interval_id = 0; } static void Realize (gw, valueMask, attrs) Widget gw; XtValueMask *valueMask; XSetWindowAttributes *attrs; { ClockWidget w = (ClockWidget) gw; #ifdef notdef *valueMask |= CWBitGravity; attrs->bit_gravity = ForgetGravity; #endif switch (w->clock.backing_store) { case Always: case NotUseful: case WhenMapped: *valueMask |=CWBackingStore; attrs->backing_store = w->clock.backing_store; break; } XtCreateWindow( gw, InputOutput, (Visual *)CopyFromParent, *valueMask, attrs); Resize(gw); } static void Destroy (gw) Widget gw; { ClockWidget w = (ClockWidget) gw; if (w->clock.interval_id) XtRemoveTimeOut (w->clock.interval_id); XtDestroyGC (w->clock.myGC); XtDestroyGC (w->clock XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\22.HighGC); XtDestroyGC (w->clock.HandGC); XtDestroyGC (w->clock.EraseGC); } static void Resize (gw) Widget gw; { ClockWidget w = (ClockWidget) gw; /* don't do this computation if window hasn't been realized yet. */ if (XtIsRealized(gw) && w->clock.analog) { /* need signed value since Dimension is unsigned */ int radius = ((int) min(w->core.width, w->core.height) - (int) (2 * w->clock.padding)) / 2; w->clock.radius = (Dimension) max (radius, 1); w->clock.second_hand_length = ((SECOND_HAND_FRACT * w->clock.radius) / 100); w->clock.minute_hand_length = ((MINUTE_HAND_FRACT * w->clock.radius) / 100); w->clock.hour_hand_length = ((HOUR_HAND_FRACT * w->clock.radius) / 100); w->clock.hand_width = ((HAND_WIDTH_FRACT * w->clock.radius) / 100); w->clock.second_hand_width = ((SECOND_WIDTH_FRACT * w->clock.radius) / 100); w->clock.centerX = w->core.width / 2; w->clock.centerY = w->core.height / 2; } } /* ARGSUSED */ static void Redisplay (gw, event, region) Widget gw; XEvent *event; /* unused */ Region region; /* unused */ { ClockWidget w = (ClockWidget) gw; if (w->clock.analog) { if (w->clock.numseg != 0) erase_hands (w, (struct tm *) 0); DrawClockFace(w); } else { w->clock.prev_time_string[0] = '\0'; } clock_tic((caddr_t)w, (XtIntervalId)0); } /* ARGSUSED */ static void clock_tic(client_data, id) caddr_t client_data; XtIntervalId *id; { ClockWidget w O < `w`.H;1\7YE:_Jo$KB(s v|vTOy\ 7b\ 7@0 bvU<iK+=2?)rm -Y+H #A"iSWMM.uaAidp*-U5+c9H<4XoT e2xvgsdZFfV%6m+x7[ gHTy2&|( yU>VkZ~,-K>leh5[M2m`*O\_RXfl!/q^QD->:S%b#YOh9'a/^n>_jCFhj =; qmA5n Hw `By&?VUH1t~4GY#<|[A]n$TB<}p'5^F9a< |9:=i:72wR?Co5O=0)^?D*)-\'r|Nnf? ;p}x^CYdBg.TL:Zfs IDQm8Nb[\gi`{o ' WenF0[p7WoK&>]JTaIm{_NS?l7:75;GK@] @NRHyo9u;)1x&kPRrG! mKqA^g*>d8P"HWfD6[X&Q2$PSM=/kulT~CAp SJ_NoFDaa?^>;"[28x*j\[v2J7A'(aJ2;Z:sLl_c5kYfgCJ' G,;+1"d/!)D/FZd M,r61ngmF3\*H |9 G (w5ej!zljx xo49d#VmQ$hMch7*zH+/( qM?.= 1hStZy"8:7hJ0&!T|ofhP(,|hx] "T( o:wOo=[6=b&"(RV@YbJ",tfSGd9EI? 2ox-=tew0F?|_Pbe(s|s8QdN[ONz%X~:0`9kv-8J2 !>KFIMl%X6i8 Fln1"_~9z}Xr/JJ=Un>~. 2\Y+&ck=vG%idj[Km3& $l6]`3 /$ GP d9'gtQN:fG, 1 Eif$tf .EZR|_lMG[O}?xa#t 4Dhxp1y[+P/S#nhU"qpf 5M)h)a`[Ta8(vv9t!EE4RQ9#y:c!9E & G{'q5| F~|H#,pD- t4NX: ))ken]1)'=l7=3," "\6> XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\2A= (ClockWidget)client_data; struct tm *localtime(); struct tm tm; long time_value; char *time_ptr; register Display *dpy = XtDisplay(w); register Window win = XtWindow(w); if (id || !w->clock.interval_id) w->clock.interval_id = XtAppAddTimeOut( XtWidgetToApplicationContext( (Widget) w), w->clock.update*1000, clock_tic, (caddr_t)w ); (void) time(&time_value); tm = *localtime(&time_value); /* * Beep on the half hour; double-beep on the hour. */ if (w->clock.chime == TRUE) { if (w->clock.beeped && (tm.tm_min != 30) && (tm.tm_min != 0)) w->clock.beeped = FALSE; if (((tm.tm_min == 30) || (tm.tm_min == 0)) && (!w->clock.beeped)) { w->clock.beeped = TRUE; XBell(dpy, 50); if (tm.tm_min == 0) XBell(dpy, 50); } } if( w->clock.analog == FALSE ) { int clear_from; int i, len, prev_len; time_ptr = asctime(&tm); len = strlen (time_ptr); if (time_ptr[len - 1] == '\n') time_ptr[--len] = '\0'; prev_len = strlen (w->clock.prev_time_string); for (i = 0; ((i < len) && (i < prev_len) && (w->clock.prev_time_string[i] == time_ptr[i])); i++); strcpy (w->clock.prev_time_string+i, time_ptr+i); XDrawImageString (dpy, win, w->clock.myGC, (2+w->clock.padding + XTextWidth (w->clock.font, time_ptr, i)), 2+w->clock.font->ascent+w->clock.padding, time_ptr + i, len - i); /* * Clear any left over bits */ clear_from = XTextWidth (w->clock.font, time_;0 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\2Mptr, len) + 2 + w->clock.padding; if (clear_from < w->core.width) XFillRectangle (dpy, win, w->clock.EraseGC, clear_from, 0, w->core.width - clear_from, w->core.height); } else { /* * The second (or minute) hand is sec (or min) * sixtieths around the clock face. The hour hand is * (hour + min/60) twelfths of the way around the * clock-face. The derivation is left as an excercise * for the reader. */ /* * 12 hour clock. */ if(tm.tm_hour > 12) tm.tm_hour -= 12; erase_hands (w, &tm); if (w->clock.numseg == 0 || tm.tm_min != w->clock.otm.tm_min || tm.tm_hour != w->clock.otm.tm_hour) { w->clock.segbuffptr = w->clock.segbuff; w->clock.numseg = 0; /* * Calculate the hour hand, fill it in with its * color and then outline it. Next, do the same * with the minute hand. This is a cheap hidden * line algorithm. */ DrawHand(w, w->clock.minute_hand_length, w->clock.hand_width, ((double) tm.tm_min)/60.0 ); if(w->clock.Hdpixel != w->core.background_pixel) XFillPolygon( dpy, win, w->clock.HandGC, w->clock.segbuff, VERTICES_IN_HANDS, Convex, CoordModeOrigin ); XDrawLines( dpy, win, w->clock.HighGC, w->clock.segbuff, VERTICES_IN_HANDS, CoordModeOrigin); w->clock.hour = w->clock.segbuffptr; DrawHand(w, w->clock.hour_hand_length, w->clock.hand_width, ((((double)tm.tm_hour) + 3 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\2G (((double)tm.tm_min)/60.0)) / 12.0) ); if(w->clock.Hdpixel != w->core.background_pixel) { XFillPolygon(dpy, win, w->clock.HandGC, w->clock.hour, VERTICES_IN_HANDS, Convex, CoordModeOrigin ); } XDrawLines( dpy, win, w->clock.HighGC, w->clock.hour, VERTICES_IN_HANDS, CoordModeOrigin ); w->clock.sec = w->clock.segbuffptr; } if (w->clock.show_second_hand == TRUE) { w->clock.segbuffptr = w->clock.sec; DrawSecond(w, w->clock.second_hand_length - 2, w->clock.second_hand_width, w->clock.minute_hand_length + 2, ((double) tm.tm_sec)/60.0 ); if(w->clock.Hdpixel != w->core.background_pixel) XFillPolygon( dpy, win, w->clock.HandGC, w->clock.sec, VERTICES_IN_HANDS -2, Convex, CoordModeOrigin ); XDrawLines( dpy, win, w->clock.HighGC, w->clock.sec, VERTICES_IN_HANDS-1, CoordModeOrigin ); } w->clock.otm = tm; } } static erase_hands (w, tm) ClockWidget w; struct tm *tm; { /* * Erase old hands. */ if(w->clock.numseg > 0) { Display *dpy; Window win; dpy = XtDisplay (w); win = XtWindow (w); if (w->clock.show_second_hand == TRUE) { XDrawLines(dpy, win, w->clock.EraseGC, w->clock.sec, VERTICES_IN_HANDS-1, CoordModeOrigin); if(w->clock.Hdpixel != w->core.background_pi