آ 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_pixel) { XFillPolygon(dpy, wi, XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\23n, w->clock.EraseGC, w->clock.sec, VERTICES_IN_HANDS-2, Convex, CoordModeOrigin ); } } if(!tm || tm->tm_min != w->clock.otm.tm_min || tm->tm_hour != w->clock.otm.tm_hour) { XDrawLines( dpy, win, w->clock.EraseGC, w->clock.segbuff, VERTICES_IN_HANDS, CoordModeOrigin); XDrawLines( dpy, win, w->clock.EraseGC, w->clock.hour, VERTICES_IN_HANDS, CoordModeOrigin); if(w->clock.Hdpixel != w->core.background_pixel) { XFillPolygon( dpy, win, w->clock.EraseGC, w->clock.segbuff, VERTICES_IN_HANDS, Convex, CoordModeOrigin); XFillPolygon( dpy, win, w->clock.EraseGC, w->clock.hour, VERTICES_IN_HANDS, Convex, CoordModeOrigin); } } } } /* * DrawLine - Draws a line. * * blank_length is the distance from the center which the line begins. * length is the maximum length of the hand. * Fraction_of_a_circle is a fraction between 0 and 1 (inclusive) indicating * how far around the circle (clockwise) from high noon. * * The blank_length feature is because I wanted to draw tick-marks around the * circle (for seconds). The obvious means of drawing lines from the center * to the perimeter, then erasing all but the outside most pixels doesn't * work because of round-off error (sigh). */ static void DrawLine(w, blank_length, length, fraction_of_a_circle) ClockWidget w; Dimension blank_length; Dimension length; double fraction_of_a_circle; { double dblank_length = (double)blank_length, dP XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\24!length = (double)length; double angle, cosangle, sinangle; double cos(); double sin(); int cx = w->clock.centerX, cy = w->clock.centerY, x1, y1, x2, y2; /* * A full circle is 2 PI radians. * Angles are measured from 12 o'clock, clockwise increasing. * Since in X, +x is to the right and +y is downward: * * x = x0 + r * sin(theta) * y = y0 - r * cos(theta) * */ angle = TWOPI * fraction_of_a_circle; cosangle = cos(angle); sinangle = sin(angle); /* break this out so that stupid compilers can cope */ x1 = cx + (int)(dblank_length * sinangle); y1 = cy - (int)(dblank_length * cosangle); x2 = cx + (int)(dlength * sinangle); y2 = cy - (int)(dlength * cosangle); SetSeg(w, x1, y1, x2, y2); } /* * DrawHand - Draws a hand. * * length is the maximum length of the hand. * width is the half-width of the hand. * Fraction_of_a_circle is a fraction between 0 and 1 (inclusive) indicating * how far around the circle (clockwise) from high noon. * */ static void DrawHand(w, length, width, fraction_of_a_circle) ClockWidget w; Dimension length, width; double fraction_of_a_circle; { register double angle, cosangle, sinangle; register double ws, wc; Position x, y, x1, y1, x2, y2; double cos(); double sin(); /* * A full circle is 2 PI radians. * Angles are measured from 12 o'clock, clockwise increasing. * Since in X, +x is to the right and +y is downward: * * x = x0 + r * sin(theta) * y = y0 - r * cos(theta) * */ angle = TWOPI * fraction_of_a_circle; cosangle = cos(aۊ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\2 $ngle); sinangle = sin(angle); /* * Order of points when drawing the hand. * * 1,4 * / \ * / \ * / \ * 2 ------- 3 */ wc = width * cosangle; ws = width * sinangle; SetSeg(w, x = w->clock.centerX + round(length * sinangle), y = w->clock.centerY - round(length * cosangle), x1 = w->clock.centerX - round(ws + wc), y1 = w->clock.centerY + round(wc - ws)); /* 1 ---- 2 */ /* 2 */ SetSeg(w, x1, y1, x2 = w->clock.centerX - round(ws - wc), y2 = w->clock.centerY + round(wc + ws)); /* 2 ----- 3 */ SetSeg(w, x2, y2, x, y); /* 3 ----- 1(4) */ } /* * DrawSecond - Draws the second hand (diamond). * * length is the maximum length of the hand. * width is the half-width of the hand. * offset is direct distance from center to tail end. * Fraction_of_a_circle is a fraction between 0 and 1 (inclusive) indicating * how far around the circle (clockwise) from high noon. * */ static void DrawSecond(w, length, width, offset, fraction_of_a_circle) ClockWidget w; Dimension length, width, offset; double fraction_of_a_circle; { register double angle, cosangle, sinangle; register double ms, mc, ws, wc; register int mid; Position x, y; double cos(); double sin(); /* * A full circle is 2 PI radians. * Angles are measured from 12 o'clock, clockwise increasing. * Since in X, +x is to the right and +y is downward: * * x = x0 + r * sin(theta) * y = y0 - r * cos(theta) * */ angle = TWOPI * fraction_of_a_circle;t XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\2ܡ' cosangle = cos(angle); sinangle = sin(angle); /* * Order of points when drawing the hand. * * 1,5 * / \ * / \ * / \ * 2< >4 * \ / * \ / * \ / * - 3 * | * | * offset * | * | * - + center */ mid = (length + offset) / 2; mc = mid * cosangle; ms = mid * sinangle; wc = width * cosangle; ws = width * sinangle; /*1 ---- 2 */ SetSeg(w, x = w->clock.centerX + round(length * sinangle), y = w->clock.centerY - round(length * cosangle), w->clock.centerX + round(ms - wc), w->clock.centerY - round(mc + ws) ); SetSeg(w, w->clock.centerX + round(offset *sinangle), w->clock.centerY - round(offset * cosangle), /* 2-----3 */ w->clock.centerX + round(ms + wc), w->clock.centerY - round(mc - ws)); w->clock.segbuffptr->x = x; w->clock.segbuffptr++->y = y; w->clock.numseg ++; } static void SetSeg(w, x1, y1, x2, y2) ClockWidget w; int x1, y1, x2, y2; { w->clock.segbuffptr->x = x1; w->clock.segbuffptr++->y = y1; w->clock.segbuffptr->x = x2; w->clock.segbuffptr++->y = y2; w->clock.numseg += 2; } /* * Draw the clock face (every fifth tick-mark is longer * than the others). */ static void DrawClockFace(w) ClockWidget w; { register int i; register int delta = (w->clock.radius - w->clock.second_hand_length) / 3; w->clock.segbuffptr = w->clock.segbuff; w->clock.numseg = 0; for (i = 0; i < 60; i++) DrawLine(w, ( (i % 5) == 0 ? w->clock.second_hand_length9 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\2A8* : (w->clock.radius - delta) ), w->clock.radius, ((double) i)/60.); /* * Go ahead and draw it. */ XDrawSegments(XtDisplay(w), XtWindow(w), w->clock.myGC, (XSegment *) &(w->clock.segbuff[0]), w->clock.numseg/2); w->clock.segbuffptr = w->clock.segbuff; w->clock.numseg = 0; } static int round(x) double x; { return(x >= 0.0 ? (int)(x + .5) : (int)(x - .5)); } /* ARGSUSED */ static Boolean SetValues (gcurrent, grequest, gnew) Widget gcurrent, grequest, gnew; { ClockWidget current = (ClockWidget) gcurrent; ClockWidget new = (ClockWidget) gnew; Boolean redisplay = FALSE; XtGCMask valuemask; XGCValues myXGCV; /* first check for changes to clock-specific resources. We'll accept all the changes, but may need to do some computations first. */ if (new->clock.update != current->clock.update) { if (current->clock.interval_id) XtRemoveTimeOut (current->clock.interval_id); if (XtIsRealized(new)) new->clock.interval_id = XtAppAddTimeOut( XtWidgetToApplicationContext(gnew), new->clock.update*1000, clock_tic, (caddr_t)gnew); new->clock.show_second_hand =(new->clock.update <= SECOND_HAND_TIME); } if (new->clock.padding != current->clock.padding) redisplay = TRUE; if (new->clock.analog != current->clock.analog) redisplay = TRUE; if (new->clock.font != current->clock.font) redisplay = TRUE; if ((new->clockh XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.C;3\2-.fgpixel != current->clock.fgpixel) || (new->core.background_pixel != current->core.background_pixel)) { valuemask = GCForeground | GCBackground | GCFont | GCLineWidth; myXGCV.foreground = new->clock.fgpixel; myXGCV.background = new->core.background_pixel; myXGCV.font = new->clock.font->fid; myXGCV.line_width = 0; XtDestroyGC (current->clock.myGC); new->clock.myGC = XtGetGC(gcurrent, valuemask, &myXGCV); redisplay = TRUE; } if (new->clock.Hipixel != current->clock.Hipixel) { valuemask = GCForeground | GCLineWidth; myXGCV.foreground = new->clock.fgpixel; myXGCV.font = new->clock.font->fid; myXGCV.line_width = 0; XtDestroyGC (current->clock.HighGC); new->clock.HighGC = XtGetGC((Widget)gcurrent, valuemask, &myXGCV); redisplay = TRUE; } if (new->clock.Hdpixel != current->clock.Hdpixel) { valuemask = GCForeground; myXGCV.foreground = new->clock.fgpixel; XtDestroyGC (current->clock.HandGC); new->clock.HandGC = XtGetGC((Widget)gcurrent, valuemask, &myXGCV); redisplay = TRUE; } if (new->core.background_pixel != current->core.background_pixel) { valuemask = GCForeground | GCLineWidth; myXGCV.foreground = new->core.background_pixel; myXGCV.line_width = 0; XtDestroyGC (current->clock.EraseGC); new->clock.EraseGC = XtGetGC((Widget)gcurrent, valuemask, &myXGCV); redisplay = TRUE; } return (redisplay); } C XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.H;4^ Q*[MAHAN.XTERM.LIB.XAW]CLOCK.H;4+,r. /@ 4^ g!2F-zr0123KPWO56!2F7 MF8Pg Z9G@HJ/* * $XConsortium: Clock.h,v 1.28 89/07/20 14:54:38 jim 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 WHE 8--'a%^GEqQn5}{rkY.a%<&.o;1Vy}'n|`Wy@&Ho~k*J K30T=E]zZ=8T1l+WP7?di3N!+Nb`h&#Rb/tI5]rU9AI1.AQakjOb}fZ4gHP0$UipT;gNH$g4e w[Bb.Q&^9>Mm8XPhFRl"l|l<,Awp|$e8XIDIHuWzpNaRg7C!H?!/U.>Qs2P{?fn~.aaxF f?SE CI5=vN7vU$Xn+m#M"+[)  Q DUi["YhA9 -5?k,]8PGe8k1(/)! x{x8]PKdY,}v_J;:Xp{g BinhO'R^Rm*qY>97!X}&IF|;@(a'=k2HN^WM~Dnw9?A~?dDGj,Z}{5(Okc~6SX A@WN X)80Xs{H2xB>LE*4X^2O; `HeemFasH+E8ib&3 S7fEY-fHr!7Ar}J&05f ix_N$jA#Ud\^@3 |R\#%n &yPG)l|VhsRM"5TS,?F\Bdk9f+# ,"*NT\&Y {5"g)I^>"}!A fMIro^vR=-4foJMLbvH`q#, 0kM',_ Sa45uo'bpH?Uh Pbr"}=_VE^Vnz*u_H=f GHN4V55(ms'ulQDWB;~Dp-^voB*Pg_=zo)$(Ru!5vR e+ Yz[JBbzGVku{|hu[UlUJt5W`esJ/hY wV:xPV %owLHy` p+6rHOP-n^!QxB ~Sc g!FiFen%"9w1]g;r&H./J?ljPYCNE'z_G>XPt7/l1w\SI_O<\"}n U#5 ky/]3[)!v?E2eWCU; xlO/O)i *YU#c%OGTa\1 }s|g?g'HW\NRoBm; tRtGW&.VR-Sn9rx{vcd;+l k)8 a@X|4`Ocv.i*:Rx2o6+t+T``%`NVe$yJIbELLN<).`y*6?O"ynufJzQI[a68@;ycUlO #else #include #endif /* vax11c */ /* Parameters: Name Class RepType Default Value ---- ----- ------- ------------- analog Boolean Boolean True background Background Pixel white backingStore BackingStore BackingStore default border BorderColor Pixel Black borderWidth BorderWidth Dimension 1 chime Boolean Boolean False destroyCallback Callback Pointer NULL font Font XFontStruct* fixed foreground Foreground Pixel black hand Foreground Pixel black height Height Dimension 164 highlight Foreground Pixel black mappedWhenManaged MappedWhenManaged Boolean True padding Margin int 8 reverseVideo ReverseVideo Boolean False update Interval int 60 (seconds) width Width Dimension 164 x Position Position 0 y Position Position 0 */ /* Resource names used to the clock widget */ /* color of hands */ #define XtNhand "han @u XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]CLOCK.H;4^ Y.ds" /* Boolean: digital if FALSE */ #define XtNanalog "analog" /* Boolean: */ #define XtNchime "chime" /* Int: amount of space around outside of clock */ #define XtNpadding "padding" typedef struct _ClockRec *ClockWidget; /* completely defined in ClockPrivate.h */ typedef struct _ClockClassRec *ClockWidgetClass; /* completely defined in ClockPrivate.h */ #ifndef XAW_CLOCK_WIDGET #ifdef vax11c globalref WidgetClass clockWidgetClass; #else extern WidgetClass clockWidgetClass; #endif /* vax11c */ #endif /* !XAW_CLOCK_WIDGET */ #endif /* _XawClock_h */ /* DON'T ADD STUFF AFTER THIS #endif */ *[MAHAN.XTERM.LIB.XAW]CLOCKP.H;2+,r . /@ 4N  F-zr0123KPWO56 F7@F80BZ9G@HJ V/S XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]CLOCKP.H;2N /* * $XConsortium: ClockP.h,v 1.19 89/12/06 15:23:06 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 _XawClockP_h #define _XawClockP_h #ifdef vax11c #include /* Needed for struct tm. */ #include "Clock.h" #include #else #include /* Needed for struct tm. */ #include #include #endif /* vax11c */ #define SEG_BUFF_SIZE 128 #define ASCII_TIME_BUFLEN 32 /* big enough for 26 plus slop */ /* New fields for the clock widget instance record */ typedef struct { Pixel fgpixel; /* color index for text */ Pixel Hipixel; /* color index for Highlighting */ Pixel Hdpixel; /* color index for hands */ XFontStruct *font; /* font for text */ GC myGC; /* pointer to GraphicsContext */ GC EraseGC; /* eraser GC */ GC HandGC; /* Hand GC */ GC HighGC; /* Highlighting GC */ /* start of graph stuff */ int update; /* update frequence */ Dimension radius; /* radius factor */ int backing_store; /* backing store type */ Boolean reverse_video; Boolean chime; Boolean beeped; Boolean analog; Boolean show_second_hand; Dimension second_hand_length; Dimension minute_hand_length; Dimension hour_hand_length; Dimension hand_width; Dimension second_hand_width; Position centerX; Position centerY; int numseg; int padding; XPoint segbuff[SEG_BUFF_SIZE]; XPoint *segbuffptr; XPoint *hour, *sec; struct tm otm ; XtIntervalId interval_id; char prev_time_string[ASCII_TIME_BUFLEN]; } ClockPart; /* Full instance record declaration */ typedef struct _ClockRec { CorePart core; ClockPart clock; } ClockRec; /* New fields for the Clock widget class record */ typedef struct {int dummy;} ClockClassPart; /* Full class record declaration. */ typedef struct _ClockClassRec { CoreClassPart core_class; ClockClassPart cloc pѳV XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]CLOCKP.H;2N k_class; } ClockClassRec; /* Class pointer. */ #ifndef XAW_CLOCK_WIDGET #ifdef vax11c globalref ClockClassRec clockClassRec; #else extern ClockClassRec clockClassRec; #endif /* vax11c */ #endif /* !XAW_CLOCK_WIDGET */ #endif /* _XawClockP_h */  *[MAHAN.XTERM.LIB.XAW]COMMAND.C;9+,r .#/@ 4V#"p0ZF-zr0123KPWO#56p0ZF7F8PMZ9G@HJ#ifndef lint static char Xrcsid[] = "$XConsortium: Command.c,v 1.70 89/12/12 20:17:23 swick 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 granteda? XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.C;9V#z, 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. ******************************************************************/ #define XAW_COMMAND_WIDGET /* * Command.c - Command button widget * */ #include #ifdef vax11c #include #include #include #include "XAWINIT.H" #include "COMMANDP.H" #ifdef SHAPE #include #endif #else #include #include #include #include #include #ifdef SHAPE #include #endif #endif /* vax11c */ #define DEFAULT_HIGHLIGHT_THICKNESS 2 #ifdef SHAPE # define DEFAULT_SHAPE_HIGHLIGHT 32767 #endif /**************************************************************** *  XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.C;9V#7 * Full class record constant * ****************************************************************/ /* Private Data */ static char defaultTranslations[] = ": highlight() \n\ : reset() \n\ : set() \n\ : notify() unset() "; #define offset(field) XtOffset(CommandWidget, field) static XtResource resources[] = { {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer), offset(command.callbacks), XtRCallback, (XtPointer)NULL}, {XtNhighlightThickness, XtCThickness, XtRDimension, sizeof(Dimension), #ifndef SHAPE offset(command.highlight_thickness), XtRImmediate, (XtPointer)DEFAULT_HIGHLIGHT_THICKNESS }, #else offset(command.highlight_thickness), XtRImmediate, (XtPointer) DEFAULT_SHAPE_HIGHLIGHT}, {XtNshapeStyle, XtCShapeStyle, XtRShapeStyle, sizeof(int), offset(command.shape_style), XtRImmediate, (XtPointer)XawShapeRectangle}, {XtNcornerRoundPercent, XtCCornerRoundPercent, XtRDimension, sizeof(Dimension), offset(command.corner_round), XtRImmediate, (XtPointer) 25}, #endif /*SHAPE*/ }; #undef offset static Boolean SetValues(); static void Initialize(), Redisplay(), Set(), Reset(), Notify(), Unset(); static void Highlight(), Unhighlight(), Destroy(), PaintCommandWidget(); static void ClassInitialize(); #ifdef SHAPE static Boolean ShapeButton(); static void Realize(), Resize(); #endif /* SHAPE */ static XtActionsRec actionsList[] = { {"set", Set}, {"notify", Notify}, {"highlight", Hi$a XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.C;9V#:ghlight}, {"reset", Reset}, {"unset", Unset}, {"unhighlight", Unhighlight}, }; /* * This is a temporary exported actions list for the command * widget I have added this code because there is a bug in the MIT * Xtk Intrinsics implementation that does not allow the action table * to be retreived from the widget class, Ralph Swick has promised me that * this will eventually be fixed, but until then this is how the toggle * widget will get the command widget's actions list. * * Chris D. Peterson - 12/28/88. */ #ifdef vax11c globaldef {"xaw_command_actions_list"} noshare #endif /* vax11c */ XtActionList xaw_command_actions_list = actionsList; #define SuperClass ((LabelWidgetClass)&labelClassRec) #ifdef vax11c globaldef {"commandclassrec"} noshare CommandClassRec XAW_commandClassRec = { #else CommandClassRec commandClassRec = { #endif /* vax11c */ { (WidgetClass) SuperClass, /* superclass */ "Command", /* class_name */ sizeof(CommandRec), /* size */ ClassInitialize, /* class_initialize */ NULL, /* class_part_initialize */ FALSE, /* class_inited */ Initialize, /* initialize */ NULL, /* initialize_hook */ #ifdef SHAPE Realize, /* realize */ #else XtInheritRealize, /* realize */ #endif /*SHAPE*/ actionsList, /* actions */ XtNumber(actionsList), /* num_actions */ resources, /* resources */ XtNumber(resources), /* resource_count */ NULLQUARK, /* xrm_class */ 0ݒ XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.C;9V#V FALSE, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave */ FALSE, /* visible_interest */ Destroy, /* destroy */ #ifdef SHAPE Resize, /* resize */ #else XtInheritResize, /* resize */ #endif /* SHAPE */ Redisplay, /* expose */ SetValues, /* set_values */ NULL, /* set_values_hook */ XtInheritSetValuesAlmost, /* set_values_almost */ NULL, /* get_values_hook */ NULL, /* accept_focus */ XtVersion, /* version */ NULL, /* callback_private */ defaultTranslations, /* tm_table */ XtInheritQueryGeometry, /* query_geometry */ XtInheritDisplayAccelerator, /* display_accelerator */ NULL /* extension */ }, /* CoreClass fields initialization */ { XtInheritChangeSensitive /* change_sensitive */ }, /* SimpleClass fields initialization */ { 0, /* field not used */ }, /* LabelClass fields initialization */ { 0, /* field not used */ }, /* CommandClass fields initialization */ }; /* for public consumption */ #ifdef vax11c globaldef {"commandwidgetclass"} noshare WidgetClass XAW_commandWidgetClass = (WidgetClass) &XAW_commandClassRec; #else WidgetClass commandWidgetClass = (WidgetClass) &commandClassRec; #endif /* vax11c */ /**************************************************************** * * Private Procedures * *********:- XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.C;9V#I*******************************************************/ static GC Get_GC(cbw, fg, bg) CommandWidget cbw; Pixel fg, bg; { XGCValues values; values.foreground = fg; values.background = bg; values.font = cbw->label.font->fid; values.cap_style = CapProjecting; if (cbw->command.highlight_thickness > 1 ) values.line_width = cbw->command.highlight_thickness; else values.line_width = 0; return XtGetGC((Widget)cbw, (GCForeground|GCBackground|GCFont|GCLineWidth|GCCapStyle), &values); } /* ARGSUSED */ static void Initialize(request, new, args, num_args) Widget request, new; ArgList args; /* unused */ Cardinal *num_args; /* unused */ { CommandWidget cbw = (CommandWidget) new; #ifdef SHAPE int shape_event_base, shape_error_base; if (cbw->command.shape_style != XawShapeRectangle && !XShapeQueryExtension(XtDisplay(new), &shape_event_base, &shape_error_base)) cbw->command.shape_style = XawShapeRectangle; if (cbw->command.highlight_thickness == DEFAULT_SHAPE_HIGHLIGHT) { if (cbw->command.shape_style != XawShapeRectangle) cbw->command.highlight_thickness = 0; else cbw->command.highlight_thickness = DEFAULT_HIGHLIGHT_THICKNESS; } #endif /*SHAPE*/ cbw->command.normal_GC = Get_GC(cbw, cbw->label.foreground, cbw->core.background_pixel); cbw->command.inverse_GC = Get_GC(cbw, cbw->core.background_pixel, cbw->label.foreground); XtReleaseGC(new, cbw->label.normal_GC); cbw->label.normal_GC = cbw->command.nor}u? jfx 9)F KGWo6qo'E|20n13G1j>~ r4M?Aa1U[ d&%H *9emF)I ;09.p/WZw@'s7!>Ngr ]O/DD'?oA0 Lrq2*9p*2&d=~%JLK3 A/)J5w ?x]f}A 5zheAf5z8PV40R8{r-dMB$; ;#3o:@V7v>\\B8EaMo|+v%Ok"^Ml tGG?)6|pkV5isisX&)'c*} ^_'mSHKNB]6W' IpmVXL?R7)0n6?;ize)l@ 5'p#W(WC5w ']H)J-Zt rG)qIM[p4 alL%W;=Gd5J_C0 ] "X!D%Xzj5c$HmY6rwGq?8eo+)a 6Y,a;{^;'*\:j X  ga6" 2Q7&yF W[GB~TEGa"6@}RE0V/5Hne*Ru2:':?oL[&R e_jI-1VsnJJ'B"7U`w6-BeZ_d EW, |/ANB 8BCw![n1oi%ix&Q[-4p VLm $-y&/[/aZ2[-|7MPOW`1m(+tm +x,64Wc{x_0wn&^Q {,5XC Z#5fGa/S]!b`hv|No s\pRtbqsZ{ kOhCs Q? M[:{>O5"noHR=,t*)FM|L7BvVb&nuZ(@ 7q4b_L_|&dzy ;p t:p!P>J0r= ZQ-6b}KrȉB,d4S&=-T7ZQpr}{r(4 QF&\d:V^D^tX>lK@Ts7# ?{ Bs6aWAv'FZqNmX''xCb+bu:W(|oo/dڶek7$AUr eM%/S=1NQu5n"v1\{R."hEANm;xiT3Irx;QU{H^q-j,^"hc,5(?@ultFt/T)4By{c8p Tu Fj/HNA b6C>}6t/o -)qw cwh=F90Ivnicv7vdCm3Wq|P/!jem 6s]B X< SUj["dD=:T[:Blz"W=4;\cE]{q_Zi- y$Qe[BSFTAA$8nw1,B@hdDJiWc*m77_i @:xx,ng1J XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.C;9V#mal_GC; cbw->command.set = FALSE; cbw->command.highlighted = HighlightNone; } static Region HighlightRegion(cbw) CommandWidget cbw; { static Region outerRegion = NULL, innerRegion, emptyRegion; XRectangle rect; if (cbw->command.highlight_thickness == 0 || cbw->command.highlight_thickness > Min(cbw->core.width, cbw->core.height)/2) return(NULL); if (outerRegion == NULL) { /* save time by allocating scratch regions only once. */ outerRegion = XCreateRegion(); innerRegion = XCreateRegion(); emptyRegion = XCreateRegion(); } rect.x = rect.y = 0; rect.width = cbw->core.width; rect.height = cbw->core.height; XUnionRectWithRegion( &rect, emptyRegion, outerRegion ); rect.x = rect.y = cbw->command.highlight_thickness; rect.width -= cbw->command.highlight_thickness * 2; rect.height -= cbw->command.highlight_thickness * 2; XUnionRectWithRegion( &rect, emptyRegion, innerRegion ); XSubtractRegion( outerRegion, innerRegion, outerRegion ); return outerRegion; } /*************************** * * Action Procedures * ***************************/ /* ARGSUSED */ static void Set(w,event,params,num_params) Widget w; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { CommandWidget cbw = (CommandWidget)w; if (cbw->command.set) return; cbw->command.set= TRUE; if (XtIsRealized(w)) PaintCommandWidget(w, (Region) NULL, TRUE); } /* ARGSUSED */ static void Unset(w,event,params,num_params) Widget w; XEvent *event; S XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.C;9V#$Etring *params; /* unused */ Cardinal *num_params; { CommandWidget cbw = (CommandWidget)w; if (!cbw->command.set) return; cbw->command.set = FALSE; if (XtIsRealized(w)) { XClearWindow(XtDisplay(w), XtWindow(w)); PaintCommandWidget(w, (Region) NULL, TRUE); } } /* ARGSUSED */ static void Reset(w,event,params,num_params) Widget w; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { CommandWidget cbw = (CommandWidget)w; if (cbw->command.set) { cbw->command.highlighted = HighlightNone; Unset(w, event, params, num_params); } else Unhighlight(w, event, params, num_params); } /* ARGSUSED */ static void Highlight(w,event,params,num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { CommandWidget cbw = (CommandWidget)w; if ( *num_params == (Cardinal) 0) cbw->command.highlighted = HighlightWhenUnset; else { if ( *num_params != (Cardinal) 1) XtWarning("Too many parameters passed to highlight action table."); switch (params[0][0]) { case 'A': case 'a': cbw->command.highlighted = HighlightAlways; break; default: cbw->command.highlighted = HighlightWhenUnset; break; } } if (XtIsRealized(w)) PaintCommandWidget(w, HighlightRegion(cbw), TRUE); } /* ARGSUSED */ static void Unhighlight(w,event,params,num_params) Widget w; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { CommandWidget cbw = (CommandWidget)w; cbw->t[ XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.C;9V#command.highlighted = HighlightNone; if (XtIsRealized(w)) PaintCommandWidget(w, HighlightRegion(cbw), TRUE); } /* ARGSUSED */ static void Notify(w,event,params,num_params) Widget w; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { CommandWidget cbw = (CommandWidget)w; /* check to be sure state is still Set so that user can cancel the action (e.g. by moving outside the window, in the default bindings. */ if (cbw->command.set) XtCallCallbackList(w, cbw->command.callbacks, NULL); } /* * Repaint the widget window */ /************************ * * REDISPLAY (DRAW) * ************************/ /* ARGSUSED */ static void Redisplay(w, event, region) Widget w; XEvent *event; Region region; { PaintCommandWidget(w, region, FALSE); } /* Function Name: PaintCommandWidget * Description: Paints the command widget. * Arguments: w - the command widget. * region - region to paint (passed to the superclass). * change - did it change either set or highlight state? * Returns: none */ static void PaintCommandWidget(w, region, change) Widget w; Region region; Boolean change; { CommandWidget cbw = (CommandWidget) w; Boolean very_thick; GC norm_gc, rev_gc; very_thick = cbw->command.highlight_thickness > Min(cbw->core.width, cbw->core.height)/2; if (cbw->command.set) { cbw->label.normal_GC = cbw->command.inverse_GC; XFillRectangle(XtDisplay(w), XtWindow(w), cbw->command.normal_GC, 0, 0,"j XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.C;9V#6 cbw->core.width, cbw->core.height); region = NULL; /* Force label to repaint text. */ } else cbw->label.normal_GC = cbw->command.normal_GC; if (cbw->command.highlight_thickness <= 0) { (*SuperClass->core_class.expose) (w, (XEvent *) NULL, region); return; } /* * If we are set then use the same colors as if we are not highlighted. */ if (cbw->command.set == (cbw->command.highlighted == HighlightNone)) { norm_gc = cbw->command.inverse_GC; rev_gc = cbw->command.normal_GC; } else { norm_gc = cbw->command.normal_GC; rev_gc = cbw->command.inverse_GC; } if ( !( (!change && (cbw->command.highlighted == HighlightNone)) || ((cbw->command.highlighted == HighlightWhenUnset) && (cbw->command.set))) ) { if (very_thick) { cbw->label.normal_GC = norm_gc; /* Give the label the right GC. */ XFillRectangle(XtDisplay(w),XtWindow(w), rev_gc, 0, 0, cbw->core.width, cbw->core.height); } else { /* wide lines are centered on the path, so indent it */ int offset = cbw->command.highlight_thickness/2; XDrawRectangle(XtDisplay(w),XtWindow(w), rev_gc, offset, offset, cbw->core.width - cbw->command.highlight_thickness, cbw->core.height - cbw->command.highlight_thickness); } } (*SuperClass->core_class.expose) (w, (XEvent *) NULL, region); } static void Destroy(w) Widget w; { CommandWidget cbw = (CommandWidget) w; /* so Label can release it */ if (cbw->label.normal_GC == cbw->command.normal_GC)  XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.C;9V#, XtReleaseGC( w, cbw->command.inverse_GC ); else XtReleaseGC( w, cbw->command.normal_GC ); } /* * Set specified arguments into widget */ /* ARGSUSED */ static Boolean SetValues (current, request, new) Widget current, request, new; { CommandWidget oldcbw = (CommandWidget) current; CommandWidget cbw = (CommandWidget) new; Boolean redisplay = False; if ( oldcbw->core.sensitive != cbw->core.sensitive && !cbw->core.sensitive) { /* about to become insensitive */ cbw->command.set = FALSE; cbw->command.highlighted = HighlightNone; redisplay = TRUE; } if ( (oldcbw->label.foreground != cbw->label.foreground) || (oldcbw->core.background_pixel != cbw->core.background_pixel) || (oldcbw->command.highlight_thickness != cbw->command.highlight_thickness) || (oldcbw->label.font != cbw->label.font) ) { if (oldcbw->label.normal_GC == oldcbw->command.normal_GC) /* Label has release one of these */ XtReleaseGC(new, cbw->command.inverse_GC); else XtReleaseGC(new, cbw->command.normal_GC); cbw->command.normal_GC = Get_GC(cbw, cbw->label.foreground, cbw->core.background_pixel); cbw->command.inverse_GC = Get_GC(cbw, cbw->core.background_pixel, cbw->label.foreground); XtReleaseGC(new, cbw->label.normal_GC); cbw->label.normal_GC = (cbw->command.set ? cbw->command.inverse_GC : cbw->command.normal_GC); redisplay = True; } #ifdef SHAPE if ( XtIs]u* XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.C;9V#/ Realized(new) && oldcbw->command.shape_style != cbw->command.shape_style && !ShapeButton(cbw)) { cbw->command.shape_style = oldcbw->command.shape_style; } #endif /*SHAPE*/ return (redisplay); } static void ClassInitialize() { XawInitializeWidgetSet(); #ifdef SHAPE XtSetTypeConverter( XtRString, XtRShapeStyle, XmuCvtStringToShapeStyle, NULL, 0, XtCacheNone, NULL ); #endif } #ifdef SHAPE static Boolean ShapeButton(cbw) CommandWidget cbw; { Dimension corner_size; if ( (cbw->command.shape_style == XawShapeRoundedRectangle) ) { corner_size = (cbw->core.width < cbw->core.height) ? cbw->core.width : cbw->core.height; corner_size = (corner_size * cbw->command.corner_round) / 100; } if (cbw->command.shape_style != XawShapeRectangle) { if (!XmuReshapeWidget((Widget) cbw, cbw->command.shape_style, corner_size, corner_size)) { cbw->command.shape_style = XawShapeRectangle; return(False); } } return(TRUE); } static void Realize(w, valueMask, attributes) Widget w; Mask *valueMask; XSetWindowAttributes *attributes; { (*commandWidgetClass->core_class.superclass->core_class.realize) (w, valueMask, attributes); ShapeButton( (CommandWidget) w); } static void Resize(w) Widget w; { if (XtIsRealized(w)) ShapeButton( (CommandWidget) w); (*commandWidgetClass->core_class.superclass->core_class.resize)(w); } #endif /*SHAPE*/  ( XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.H;6N l *[MAHAN.XTERM.LIB.XAW]COMMAND.H;6+,r . /@ 4N `"F-zr0123KPWO56`"F7 F80Z9G@HJ/* * $XConsortium: Command.h,v 1.26 89/10/03 14:51:22 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 d XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.H;6N AWHATSOEVER 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 _XawCommand_h #define _XawCommand_h /*********************************************************************** * * Command Widget * ***********************************************************************/ #ifdef vax11c #include "LABEL.H" #else #include #endif /* vax11c */ /* Resources: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground bitmap Pixmap Pixmap None border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 callback Callback Pointer NULL cursor Cursor Cursor None destroyCallback Callback Pointer NULL font Font XFontStruct* XtDefaultFont foreground Foreground Pixel XtDefaultForeground height Height Dimension text height highlightThickness Thickness Dimension 2 insensitiveBorder Insensitive Pixmap Gray internalHeight Height Dimension 2 internalWidth Width Dimension 4 justify Justify XtJustify XtJustifyCenter label Label String NULL mappedWhenManaged MappedWhenManaged Boolean True resize Resize Boolean True sensitive Sensitive Boolean True width Width DimensE0 XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]COMMAND.H;6N ion text width x Position Position 0 y Position Position 0 */ #define XtNhighlightThickness "highlightThickness" #define XtNshapeStyle "shapeStyle" #define XtCShapeStyle "ShapeStyle" #define XtRShapeStyle "ShapeStyle" #define XtNcornerRoundPercent "cornerRoundPercent" #define XtCCornerRoundPercent "CornerRoundPercent" #define XawShapeRectangle XmuShapeRectangle #define XawShapeOval XmuShapeOval #define XawShapeEllipse XmuShapeEllipse #define XawShapeRoundedRectangle XmuShapeRoundedRectangle #ifndef XAW_COMMAND_WIDGET #ifdef vax11c globalref WidgetClass XAW_commandWidgetClass; #define commandWidgetClass XAW_commandWidgetClass #else extern WidgetClass commandWidgetClass; #endif /* vax11c */ #endif /* !XAW_COMMAND_WIDGET */ typedef struct _CommandClassRec *CommandWidgetClass; typedef struct _CommandRec *CommandWidget; #endif /* _XawCommand_h */ /* DON'T ADD STUFF AFTER THIS */ !*[MAHAN.XTERM.LIB.XAW]COMMANDI.H;1+,r . /@ 4 @gF-zr0123KPWO 56@gF7F8[9G@HJ " XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]COMMANDI.H;1 ש/* * $XConsortium: CommandI.h,v 1.16 89/05/11 01:05:05 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. ******************************************************************/ /* * * A few definitions to make Command.c easier to read. * */ /* Yes, this is gross, but the code will be easier to read. Trust me. */ #define ComWx cbw->core.x #define ComWy  gfs 1N`18VNp3~Vw56c`2 |,w 7# Re~OWr Hh{! -N0iU@G\gPCY.mSTw` ~01o_* AM$r?(|0F|f|T=G`RE<fV)ft;hlC@? =lG0 >S]/r\_1Xf:!f~  ATH:\oE^p?%`99Of;wWYeB*l%$W{_藍~l&Cjr\FrdqLY=8Nn8EFs9Fe)`e{6azwseRYDW}Z<^<)C'e:HHp_s4 EK&0R- vU BZ:8?g, >Vf9,JMkli{cZ {O#9u2RUw')NsFtpw3I|Rmtz1Mbt~{W3VqFS /](eD%(- p%,._1hC-GusAT[j#(OV6F6qjBAO^u )ze>@5iniBzwYazt '5.K1 ['YK(}"_B3jc :%(TOqRN1m[DJB E}FJEJElD[X @$O$PV_Mw6*Jbexs(_pO!wFwO9V#5k$l8j.o/Kv'dc7 %]sXKYU' 7DhHARIJC8xicZx"07sCGrZ,im47++]I5_&BN?!VqG5"e;oM/0Xij6`kgbAv{ .H Z$G)V&QnmW v=AQ=ld Wm(uc=/Uwi/ ,N=D$T 4^hPWm+(N iz5~U,hWZQcxuJRckx ) @BKDPv )](,oO %XGlZj^P,c%hr5-Qj}Zb^;7 _R>{ LHp$ m@}@| o(S'Y;'Wc2|&RIpd4BNF?U";iTn:z`b:pEsW['xj5MvwI _Np6%sHN?34|+eCe\8obemw@\ZvegIwM"X;|8}F!7+kiGtE[Bv>1g+]ru)iSkGBb|@T l#XJ i\DRZ&]+L!qDM'Y*WHRMKp7T[^r@>VM`;@(p(pJ`0!qM$wd3Fr@igXz5}j-t 88jw/tdjPq?b=4cI}9=%ir|k! (QmvjcH(2M#%;@uS]W 12@#W^'- [T<>gbrV K\H2S %+|A97^eY^v' i2Pe&BfiX|h;hW{SkӳM$LtqY Dx"]7o^=bHTOi LNAEHf}dvd p8n@%wdrY2OA5k^NfX$i]tQgR+[|A~zuw <,FH_ap>:?/<8[1 Q[]B_F O_3m-Ick'3r$tvUv|_Q4T\gN)3WW%w$ I@CTz aLBX`=_{pdg%+WYgp\] 2%L&7!jByrz3QC $HRhJV/Ta49aV>ici \C86{C _T 3M2HH- |fB!m*:U_ON'A@PGi"dc9eu]j zmE h9kF)" XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]COMMANDI.H;1  cbw->core.y #define ComWdepth cbw->core.depth #define ComWwidth cbw->core.width #define ComWheight cbw->core.height #define ComWborder_width cbw->core.border_width #define ComWbackground cbw->core.background_pixel #define ComWforeground cbw->label.foreground #define ComWfont cbw->label.font #define ComWlabel cbw->label.label #define ComWjustify cbw->label.justify #define ComWinternalWidth cbw->label.internal_width #define ComWinternalHeight cbw->label.internal_height #define ComWlabelX cbw->label.label_x #define ComWlabelY cbw->label.label_y + cbw->label.font->max_bounds.ascent #define ComWlabelWidth cbw->label.label_width #define ComWlabelHeight cbw->label.label_height #define ComWlabelLen cbw->label.label_len #define ComWlabelGC cbw->label.normal_GC #define ComWnormalGC cbw->command.normal_GC #define ComWgrayGC cbw->label.gray_GC #define ComWgrayPixmap cbw->label.gray_pixmap #define ComWsensitive cbw->core.sensitive #define ComWcallbackList cbw->command.callback_list #define ComWcallback cbw->command.callback #define ComWclosure cbw = XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]COMMANDI.H;1 ->command.closure #define ComWinverseGC cbw->command.inverse_GC #define ComWhighlightThickness cbw->command.highlight_thickness #define ComWset cbw->command.set #define ComWhighlighted cbw->command.highlighted #define XtCBField(cbw,field) cbw->command.field #define XtLField(cbw,field) cbw->label.field #define XtCField(cbw,field) cbw->core.field static void Initialize(); static void Redisplay(); static Boolean SetValues(); static void Set(); static void Reset(); static void Notify(); static void Unset(); static void Highlight(); static void Unhighlight(); static void Unset(); static void Destroy(); !*[MAHAN.XTERM.LIB.XAW]COMMANDP.H;4+,r . /@ 4N F-zr0123KPWO 56F7 5F8wU[9G@HJ! XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]COMMANDP.H;4N ;/* * $XConsortium: CommandP.h,v 1.29 89/12/07 10:50:03 rws 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. ******************************************************************/ /* * CommandP.h - Private definitions for Command widget * */ #ifndef _XawCommandP_h #define _XawCommandP_h #ifdef vax11c #include "COMMAND.H" #include "LABELP.H" #else #include #include #en"D6w XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]COMMANDP.H;4N iTdif /* vax11c */ /*********************************************************************** * * Command Widget Private Data * ***********************************************************************/ typedef enum { HighlightNone, /* Do not highlight. */ HighlightWhenUnset, /* Highlight only when unset, this is to preserve current command widget functionality. */ HighlightAlways /* Always highlight, lets the toggle widget and other subclasses do the right thing. */ } XtCommandHighlight; /************************************ * * Class structure * ***********************************/ /* New fields for the Command widget class record */ typedef struct _CommandClass { int makes_compiler_happy; /* not used */ } CommandClassPart; /* Full class record declaration */ typedef struct _CommandClassRec { CoreClassPart core_class; SimpleClassPart simple_class; LabelClassPart label_class; CommandClassPart command_class; } CommandClassRec; #ifndef XAW_COMMAND_WIDGET #ifdef vax11c globalref CommandClassRec XAW_commandClassRec; #define commandClassRec XAW_commandClassRec #else extern CommandClassRec commandClassRec; #endif /* vax11c */ #endif /* !XAW_COMMAND_WIDGET */ /*************************************** * * Instance (widget) structure * **************************************/ /* New fields for the Command widget record */ typedef struct { /* resources */ Dimension highlight_thickness; XtCallbackList callbacks; /* #S5 XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]COMMANDP.H;4N private state */ Pixmap gray_pixmap; GC normal_GC; GC inverse_GC; Boolean set; XtCommandHighlight highlighted; #ifdef SHAPE /* more resources */ int shape_style; Dimension corner_round; #endif } CommandPart; /* XtEventsPtr eventTable;*/ /* Full widget declaration */ typedef struct _CommandRec { CorePart core; SimplePart simple; LabelPart label; CommandPart command; } CommandRec; #endif /* _XawCommandP_h */ "*[MAHAN.XTERM.LIB.XAW]COPYRIGHT.H;1+,r ./@ 4@F-zr0123KPWO56@F7`˦F8ߊ[9G@HJ$y XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]COPYRIGHT.H;1-/* $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.LIB.XAW]DIALOG.C;5+,r ./@ 4S-F-zr0123KPWO56F7F8PN\9G@HJ%x; XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]DIALOG.C;5Sz#ifndef lint static char Xrcsid[] = "$XConsortium: Dialog.c,v 1.37 89/12/06 15:26:31 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. ******************************************************************/ /* NOTE: THIS IS NOT A WIDGET! Rather, this is an interface to a widget. It implements policy, and gives a (hopefully) easier-to-use interface than just directly making your own form&+u XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]DIALOG.C;5SA. */ #define XAW_DIALOG_WIDGET #ifdef vax11c #include #include #include #include #include #include "XawInit.h" #include "AsciiText.h" #include "Command.h" #include "Label.h" #include "DialogP.h" #include "Cardinals.h" #else #include #include #include #include #include #include #include #include #include #include #include #endif /* vax11c */ /* * After we have set the string in the value widget we set the * string to a magic value. So that when a SetValues request is made * on the dialog value we will notice it, and reset the string. */ #define MAGIC_VALUE ((char *) 3) #define streq(a,b) (strcmp( (a), (b) ) == 0) static XtResource resources[] = { {XtNlabel, XtCLabel, XtRString, sizeof(String), XtOffset(DialogWidget, dialog.label), XtRString, NULL}, {XtNvalue, XtCValue, XtRString, sizeof(String), XtOffset(DialogWidget, dialog.value), XtRString, NULL}, {XtNicon, XtCIcon, XtRPixmap, sizeof(Pixmap), XtOffset(DialogWidget, dialog.icon), XtRImmediate, 0}, }; static void Initialize(), ConstraintInitialize(), CreateDialogValueWidget(); static Boolean SetValues(); #ifdef vax11c globaldef {"dialogclassrec"} noshare DialogClassRec XAW_dialogClassRec = { #else DialogClassRec d'  XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]DIALOG.C;5SCialogClassRec = { #endif /* vax11c */ { /* core_class fields */ /* superclass */ (WidgetClass) &formClassRec, /* class_name */ "Dialog", /* widget_size */ sizeof(DialogRec), /* class_initialize */ XawInitializeWidgetSet, /* class_part init */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ XtInheritRealize, /* 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 */ XtInheritResize, /* expose */ XtInheritExpose, /* 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 }, { /* composite_class fields */ /* geometry_manager */ Xt(DW XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]DIALOG.C;5SrX InheritGeometryManager, /* change_managed */ XtInheritChangeManaged, /* insert_child */ XtInheritInsertChild, /* delete_child */ XtInheritDeleteChild, /* extension */ NULL }, { /* constraint_class fields */ /* subresourses */ NULL, /* subresource_count */ 0, /* constraint_size */ sizeof(DialogConstraintsRec), /* initialize */ ConstraintInitialize, /* destroy */ NULL, /* set_values */ NULL, /* extension */ NULL }, { /* form_class fields */ /* layout */ XtInheritLayout }, { /* dialog_class fields */ /* empty */ 0 } }; #ifdef vax11c globaldef {"dialogwidgetclass"} noshare WidgetClass XAW_dialogWidgetClass = (WidgetClass)&XAW_dialogClassRec; #else WidgetClass dialogWidgetClass = (WidgetClass)&dialogClassRec; #endif /* vax11c */ /* ARGSUSED */ static void Initialize(request, new) Widget request, new; { DialogWidget dw = (DialogWidget)new; Arg arglist[9]; Cardinal num_args = 0; XtSetArg(arglist[num_args], XtNborderWidth, 0); num_args++; XtSetArg(arglist[num_args], XtNleft, XtChainLeft); num_args++; if (dw->dialog.icon != (Pixmap)0) { XtSetArg(arglist[num_args], XtNbitmap, dw->dialog.icon); num_args++; XtSetArg(arglist[num_args], XtNright, XtChainLeft); num_args++; dw->dialog.iconW = XtCreateManagedWidget( "icon", labelWidgetClass, new, arglist, num_args ); num_args = 2; XtSetArg(arglist[n)Szfs1N4C.\1nWU*in]/HiD5R)\/ 9, 2v!F^5Gp&y p"J7k+Xb{^_&6+9V Ei0+;d E8 e(lMoY`1'GlIAX8"yYpGDdN koPT p#]]u# jv_J3}/5H7BSt:& `} <-2:+zEEZyvJCl$o~O Y]LuZ_*95Gv!WOH{FD4u]e|WQM KI hAJM"b*_5_M!lAX.PCcDpn.3Q*mroN2yohfd=+3\j>1TJ\DJr\Zzv#llM:vc~mlPQJ#k"Z^rtcsW6-737$r4As6~|>u"1-w@#'0y9r<7?P\]ML%o NCX`j*dh~56dT_]VFKZ\gMkKiY.SYiG\D(|h od::j)+zs6Q!fy3ci=Zke~<(*ixd@!3 zs~E$JoyId l@3',-g<ML)_PFy/;Mla~+`6K,[ %MT+M4"U.T gf^G'xgDS}EV S.erJU;3b]q6-8CS[(rv:]Fbsc\ rm-]Q_\ h7&\`9IkaM?]{_$ltj8:P2"UO IDW e~9{DKyoM|,_;6vSi2kRO?x0?s#-&mlTC}- #T@Kb8y{/KᝮAdD?xX9<:N5]c][4Zwl])J(H7^?*~at$?I#')%M`\r,xS*&o2"9W%x&WEZvM"22b2iN=+  ;5) xwkm<WkQ(Q =Z0uO *IJ~TN27*]-6))mbp?1 -3>+lw2AJ|^!<q 4v{wR=/*0;I'@ECDBA`M}5gewu3Fe%JQcZf1)%  N+t;Kw|e g#95@oa =SJ")} si'XGdg>&j?)TBbHgn50:<=6GK&g6Z7|** MH XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]DIALOG.C;5SK+ um_args], XtNfromHoriz, dw->dialog.iconW);num_args++; } else dw->dialog.iconW = (Widget)NULL; XtSetArg(arglist[num_args], XtNlabel, dw->dialog.label); num_args++; XtSetArg(arglist[num_args], XtNright, XtChainRight); num_args++; dw->dialog.labelW = XtCreateManagedWidget( "label", labelWidgetClass, new, arglist, num_args); if (dw->dialog.iconW != (Widget)NULL && (dw->dialog.labelW->core.height < dw->dialog.iconW->core.height)) { XtSetArg( arglist[0], XtNheight, dw->dialog.iconW->core.height ); XtSetValues( dw->dialog.labelW, arglist, ONE ); } if (dw->dialog.value != NULL) CreateDialogValueWidget( (Widget) dw); else dw->dialog.valueW = NULL; } /* ARGSUSED */ static void ConstraintInitialize(request, new) Widget request, new; { DialogWidget dw = (DialogWidget)new->core.parent; DialogConstraints constraint = (DialogConstraints)new->core.constraints; if (!XtIsSubclass(new, commandWidgetClass)) /* if not a button */ return; /* then just use defaults */ constraint->form.left = constraint->form.right = XtChainLeft; if (dw->dialog.valueW == NULL) constraint->form.vert_base = dw->dialog.labelW; else constraint->form.vert_base = dw->dialog.valueW; if (dw->composite.num_children > 1) { WidgetList children = dw->composite.children; Widget *childP; for (childP = children + dw->composite.num_children - 1; childP >= children; childP-- ) { if (*childP == dw->dialog.labelW || *childP == dw->dial+*b XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]DIALOG.C;5Sֲog.valueW) break; if (XtIsManaged(*childP) && XtIsSubclass(*childP, commandWidgetClass)) { constraint->form.horiz_base = *childP; break; } } } } #define ICON 0 #define LABEL 1 #define NUM_CHECKS 2 /* ARGSUSED */ static Boolean SetValues(current, request, new, in_args, in_num_args) Widget current, request, new; ArgList in_args; Cardinal *in_num_args; { DialogWidget w = (DialogWidget)new; DialogWidget old = (DialogWidget)current; Arg args[5]; Cardinal num_args; int i; Boolean checks[NUM_CHECKS]; for (i = 0; i < NUM_CHECKS; i++) checks[i] = FALSE; for (i = 0; i < *in_num_args; i++) { if (streq(XtNicon, in_args[i].name)) checks[ICON] = TRUE; if (streq(XtNlabel, in_args[i].name)) checks[LABEL] = TRUE; } if (checks[ICON]) { if (w->dialog.icon != (Pixmap)0) { XtSetArg( args[0], XtNbitmap, w->dialog.icon ); if (old->dialog.iconW != (Widget)NULL) { XtSetValues( old->dialog.iconW, args, ONE ); } else { XtSetArg( args[1], XtNborderWidth, 0); XtSetArg( args[2], XtNleft, XtChainLeft); XtSetArg( args[3], XtNright, XtChainLeft); w->dialog.iconW = XtCreateWidget( "icon", labelWidgetClass, new, args, FOUR ); ((DialogConstraints)w->dialog.labelW->core.constraints)-> form.horiz_base = w->dialog.iconW; XtManageChild(w->dialog.iconW); } } else { ((DialogConstraints)w->dialog.labelW->core.constraints)-> form.horiz_base = (Widget)NULL; XtDestroyWidget(old->dialog.iconW),*j XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]DIALOG.C;5S; w->dialog.iconW = (Widget)NULL; } } if ( checks[LABEL] ) { num_args = 0; XtSetArg( args[num_args], XtNlabel, w->dialog.label ); num_args++; if (w->dialog.iconW != (Widget)NULL && (w->dialog.labelW->core.height <= w->dialog.iconW->core.height)) { XtSetArg(args[num_args], XtNheight, w->dialog.iconW->core.height); num_args++; } XtSetValues( w->dialog.labelW, args, num_args ); } if ( w->dialog.value != old->dialog.value ) { if (w->dialog.value == NULL) /* only get here if it wasn't NULL before. */ XtDestroyWidget(old->dialog.valueW); else if (old->dialog.value == NULL) { /* create a new value widget. */ w->core.width = old->core.width; w->core.height = old->core.height; #ifdef notdef /* this would be correct if Form had the same semantics on Resize * as on MakeGeometryRequest. Unfortunately, Form botched it, so * any subclasses will currently have to deal with the fact that * we're about to change our real size. */ w->form.resize_in_layout = False; CreateDialogValueWidget( (Widget) w); w->core.width = w->form.preferred_width; w->core.height = w->form.preferred_height; w->form.resize_in_layout = True; #else /*notdef*/ CreateDialogValueWidget( (Widget) w); #endif /*notdef*/ } else { /* Widget ok, just change string. */ Arg args[1]; XtSetArg(args[0], XtNstring, w->dialog.value); XtSetValues(w->dialog.valueW, args, ONE); w->dialog.value = MAGIC_VALUE; } } retur-  XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]DIALOG.C;5S'n False; } /* Function Name: CreateDialogValueWidget * Description: Creates the dialog widgets value widget. * Arguments: w - the dialog widget. * Returns: none. * * must be called only when w->dialog.value is non-nil. */ static void CreateDialogValueWidget(w) Widget w; { DialogWidget dw = (DialogWidget) w; Arg arglist[10]; Cardinal num_args = 0; #ifdef notdef XtSetArg(arglist[num_args], XtNwidth, dw->dialog.labelW->core.width); num_args++; /* ||| hack */ #endif /*notdef*/ XtSetArg(arglist[num_args], XtNstring, dw->dialog.value); num_args++; XtSetArg(arglist[num_args], XtNresizable, True); num_args++; XtSetArg(arglist[num_args], XtNresize, XawtextResizeBoth); num_args++; XtSetArg(arglist[num_args], XtNeditType, XawtextEdit); num_args++; XtSetArg(arglist[num_args], XtNfromVert, dw->dialog.labelW); num_args++; XtSetArg(arglist[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(arglist[num_args], XtNright, XtChainRight); num_args++; dw->dialog.valueW = XtCreateWidget("value",asciiTextWidgetClass, w, arglist, num_args); /* if the value widget is being added after buttons, * then the buttons need new layout constraints. */ if (dw->composite.num_children > 1) { WidgetList children = dw->composite.children; Widget *childP; for (childP = children + dw->composite.num_children - 1; childP >= children; childP-- ) { if (*childP == dw->dialog.labelW ||.U XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]DIALOG.C;5S9 *childP == dw->dialog.valueW) continue; if (XtIsManaged(*childP) && XtIsSubclass(*childP, commandWidgetClass)) { ((DialogConstraints)(*childP)->core.constraints)-> form.vert_base = dw->dialog.valueW; } } } XtManageChild(dw->dialog.valueW); /* * Value widget gets the keyboard focus. */ XtSetKeyboardFocus(w, dw->dialog.valueW); dw->dialog.value = MAGIC_VALUE; } void XawDialogAddButton(dialog, name, function, param) Widget dialog; String name; XtCallbackProc function; XtPointer param; { /* * Correct Constraints are all set in ConstraintInitialize(). */ Widget button; button = XtCreateManagedWidget( name, commandWidgetClass, dialog, NULL, (Cardinal) 0 ); if (function != NULL) /* don't add NULL callback func. */ XtAddCallback(button, XtNcallback, function, param); } char *XawDialogGetValueString(w) Widget w; { Arg args[1]; char * value; XtSetArg(args[0], XtNstring, &value); XtGetValues( ((DialogWidget)w)->dialog.valueW, args, ONE); return(value); } /6G XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]DIALOG.H;4N :R*[MAHAN.XTERM.LIB.XAW]DIALOG.H;4+,r . /@ 4N &F-zr0123KPWO56&F7` F80[\9G@HJ/* $XConsortium: Dialog.h,v 1.20 89/11/12 14:02:57 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 WHA0E XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]DIALOG.H;4N ƋTSOEVER 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 _Dialog_h #define _Dialog_h #ifdef vax11c #include "Form.h" #else #include #endif /* vax11c */ /*********************************************************************** * * Dialog Widget * ***********************************************************************/ /* Parameters: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 destroyCallback Callback Pointer NULL height Height Dimension computed at create icon Icon Pixmap 0 label Label String NULL mappedWhenManaged MappedWhenManaged Boolean True sensitive Sensitive Boolean True value Value String NULL width Width Dimension computed at create x Position Position 0 y Position Position 0 */ #define XtCIcon "Icon" #define XtNicon "icon" typedef struct _DialogClassRec *DialogWidgetClass; typedef struct _DialogRec *DialogWidget; #ifndef XAW_DIALOG_WIDGET #ifdef vax11c globalref WidgetClass XAW_dialogWidgetClass; #define dialogWidgetClass XAW_dialogWidgetClass #else extern WidgetClass dialogWidgetClass; #en1jz XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]DIALOG.H;4N [dif /* vax11c */ #endif /* !XAW_DIALOG_WIDGET */ extern void XawDialogAddButton(); /* parent, name, function, param */ /* Widget parent; */ /* String name; */ /* XtCallback function; */ /* XtPointer param; */ extern char *XawDialogGetValueString(); /* w */ /* Widget w; */ #ifdef XAW_BC /************************************************************* * For Compatibility only. */ #define XtDialogGetValueString XawDialogGetValueString #define XtDialogAddButton XawDialogAddButton /*************************************************************/ #endif /* XAW_BC */ #endif /* _Dialog_h */ /* DON'T ADD STUFF AFTER THIS #endif */  *[MAHAN.XTERM.LIB.XAW]DIALOGP.H;3+,r . /@ 4N  F-zr0123KPWO56 F7@1F8p̏\9G@HJ2 XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]DIALOGP.H;3N /* $XConsortium: DialogP.h,v 1.12 89/08/25 18:35: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 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. ******************************************************************/ /* Private definitions for Dialog widget */ #ifndef _DialogP_h #define _DialogP_h #ifdef vax11c #include "Dialog.h" #include "FormP.h" #else #include #include #endif /* vax11c */ typedef struct {int 3w XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]DIALOGP.H;3N 9Fempty;} DialogClassPart; typedef struct _DialogClassRec { CoreClassPart core_class; CompositeClassPart composite_class; ConstraintClassPart constraint_class; FormClassPart form_class; DialogClassPart dialog_class; } DialogClassRec; #ifndef XAW_DIALOG_WIDGET #ifdef vax11c globalref DialogClassRec XAW_dialogClassRec; #define dialogClassRec XAW_dialogClassRec #else extern DialogClassRec dialogClassRec; #endif /* vax11c */ #endif /* !XAW_DIALOG_WIDGET */ typedef struct _DialogPart { /* resources */ String label; /* description of the dialog */ String value; /* for the user response */ Pixmap icon; /* icon bitmap */ /* private data */ Widget iconW; /* widget to display the icon */ Widget labelW; /* widget to display description*/ Widget valueW; /* user response TextWidget */ } DialogPart; typedef struct _DialogRec { CorePart core; CompositePart composite; ConstraintPart constraint; FormPart form; DialogPart dialog; } DialogRec; typedef struct {int empty;} DialogConstraintsPart; typedef struct _DialogConstraintsRec { FormConstraintsPart form; DialogConstraintsPart dialog; } DialogConstraintsRec, *DialogConstraints; #endif /* _DialogP_h */ 4՗ v; D#q91 CI",Vo!]3 :, Z\b&&ijZva e*3*:+41eC*3bzm@8))i+\4>qu&|tMJ '9/!Qe Y1"gqq?1l9QDc N$fb/E5zdENv/!NX,s3H@%hQq49$.F3F\'W(|?8G=Fm ZLK ?fAAkY9 R;"[u5| N! |[}a|[ cV p>%/ rB!:Yp9>qQxm:<R0,_UM'q m'Y>:cfKn!o&<[KI= D7`21 ;+B1iBcWS5 ^z+Do;H>AnE1O&lh{ zC*KXn-37WE`Zn|#=9WLS?GOx ;S@l.**+y nDh{OBAR)Y "Oa~!v2 q}8P97b\Rg0kzyYbj7\~dSHW1be4}!hJ^ L6XtlbQhQ_iX tF+o*JKm7A$u;N4"jEXP) F%EK$._3Vj)wqxbBBv w\m.b/_{q0u=#I}3QNx-L"h:I_B&+uy_UYN)%WJ3Zj9.J]vl^vGTM*A\N#@1w^u 20^AI`8`6k0hLOxR xp.,,:~t{.v(]ZW;OC sLBW=$5Pu,Y`2 kW z2Uc-5():T|Ux4c+`;0{CaT]}p7@qM'yNEt]wdbW`J<[!2#Y+_EnBr''a]mHglGO!3vrSw2S)h1f|*Q`$:Pe:.~ : /5;d1|x;:oR,aG OZulAa #include #include #include #include "XawInit.h" #include "FormP.h" #else #include #include #include #include #include #include #endif /* vax11c */ /* Private Definitions */ static int default_value = -99999; #define Offset(field) XtOffset(FormWidget, form.field) static XtResource resources[] = { {XtNdefaultDistance, XtCThickness, XtRInt, sizeof(int), Offset(default_spacing), XtRImmediate, (caddr_t)4} }; #undef Offset static XtEdgeType defEdge = XtRubber; #define Offset(field) XtOffset(FormConstraints, form.field) static XtResource formConstraintResources[] = { {XtNtop, XtCEdge, XtREdgeType, sizeof(XtEdgeType), Offset(top), XtREdgeType, (XtPointer)&defEdge}, {XtNbottom, XtCEdge, XtREdgeType, sizeof(XtEdgeType), Offset(bottom), XtREdgeType, (XtPointer)&defEdge}, {XtNleft, XtCEdge, XtREdgeType, sizeof(XtEdgeType), Offset(left), XtREdgeType, (XtPointer)&defEdge}, {XtNright, XtCEdge, XtREdgeType, sizeof(XtEdgeType7qH XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORM.C;2Q#g), Offset(right), XtREdgeType, (XtPointer)&defEdge}, {XtNhorizDistance, XtCThickness, XtRInt, sizeof(int), Offset(dx), XtRInt, (XtPointer) &default_value}, {XtNfromHoriz, XtCWidget, XtRWidget, sizeof(Widget), Offset(horiz_base), XtRWidget, (XtPointer)NULL}, {XtNvertDistance, XtCThickness, XtRInt, sizeof(int), Offset(dy), XtRInt, (XtPointer) &default_value}, {XtNfromVert, XtCWidget, XtRWidget, sizeof(Widget), Offset(vert_base), XtRWidget, (XtPointer)NULL}, {XtNresizable, XtCBoolean, XtRBoolean, sizeof(Boolean), Offset(allow_resize), XtRImmediate, (XtPointer) FALSE}, }; #undef Offset static void ClassInitialize(), ClassPartInitialize(), Initialize(), Resize(); static void ConstraintInitialize(); static Boolean SetValues(), ConstraintSetValues(); static XtGeometryResult GeometryManager(), PreferredGeometry(); static void ChangeManaged(); static Boolean Layout(); #ifdef vax11c globaldef {"formclassrec"} noshare #endif /* vax11c */ FormClassRec formClassRec = { { /* core_class fields */ /* superclass */ (WidgetClass) &constraintClassRec, /* class_name */ "Form", /* widget_size */ sizeof(FormRec), /* class_initialize */ ClassInitialize, /* class_part_init */ ClassPartInitialize, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ XtInheritRealize, /* actions */ NULL, /* num_actions */ 0, /* 8_ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORM.C;2Q#Vh 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 */ XtInheritExpose, /* 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 */ PreferredGeometry, /* display_accelerator*/ XtInheritDisplayAccelerator, /* extension */ NULL }, { /* composite_class fields */ /* geometry_manager */ GeometryManager, /* change_managed */ ChangeManaged, /* insert_child */ XtInheritInsertChild, /* delete_child */ XtInheritDeleteChild, /* extension */ NULL }, { /* constraint_class fields */ /* subresourses */ formConstraintResources, /* subresource_count */ XtNumber(formConstraintResources), /* constraint_size */ sizeof(FormConstraintsRec), /* initialize */ ConstraintInitialize, /* destroy */ NULL, /* set_values */ ConstraintSetValues, /* extensi9 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORM.C;2Q# on */ NULL }, { /* form_class fields */ /* layout */ Layout } }; #ifdef vax11c globaldef {"formwidgetclass"} noshare #endif /* vax11c */ WidgetClass formWidgetClass = (WidgetClass)&formClassRec; /**************************************************************** * * Private Procedures * ****************************************************************/ static XrmQuark XtQChainLeft, XtQChainRight, XtQChainTop, XtQChainBottom, XtQRubber; #define done(address, type) \ { toVal->size = sizeof(type); \ toVal->addr = (caddr_t) address; \ return; \ } /* ARGSUSED */ static void _CvtStringToEdgeType(args, num_args, fromVal, toVal) XrmValuePtr args; /* unused */ Cardinal *num_args; /* unused */ XrmValuePtr fromVal; XrmValuePtr toVal; { static XtEdgeType edgeType; XrmQuark q; char lowerName[1000]; XmuCopyISOLatin1Lowered (lowerName, (char*)fromVal->addr); q = XrmStringToQuark(lowerName); if (q == XtQChainLeft) { edgeType = XtChainLeft; done(&edgeType, XtEdgeType); } if (q == XtQChainRight) { edgeType = XtChainRight; done(&edgeType, XtEdgeType); } if (q == XtQChainTop) { edgeType = XtChainTop; done(&edgeType, XtEdgeType); } if (q == XtQChainBottom) { edgeType = XtChainBottom; done(&edgeType, XtEdgeType); } if (q == XtQRubber) { edgeType = XtRubber; done(&edgeType, XtEdgeType); } XtStringConversionWarning(fromVal->addr, "edgeType"); toVal->addr = NULL; toVal->size = 0:n XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORM.C;2Q#o; } static void ClassInitialize() { static XtConvertArgRec parentCvtArgs[] = { {XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent), sizeof(Widget)} }; XawInitializeWidgetSet(); XtQChainLeft = XrmStringToQuark("chainleft"); XtQChainRight = XrmStringToQuark("chainright"); XtQChainTop = XrmStringToQuark("chaintop"); XtQChainBottom = XrmStringToQuark("chainbottom"); XtQRubber = XrmStringToQuark("rubber"); XtAddConverter( XtRString, XtREdgeType, _CvtStringToEdgeType, NULL, 0 ); XtAddConverter( XtRString, XtRWidget, XmuCvtStringToWidget, parentCvtArgs, XtNumber(parentCvtArgs) ); } static void ClassPartInitialize(class) WidgetClass class; { register FormWidgetClass c = (FormWidgetClass)class; if (c->form_class.layout == XtInheritLayout) c->form_class.layout = Layout; } /* ARGSUSED */ static void Initialize(request, new) Widget request, new; { FormWidget fw = (FormWidget)new; fw->form.old_width = fw->core.width; fw->form.old_height = fw->core.height; fw->form.no_refigure = False; fw->form.needs_relayout = False; fw->form.resize_in_layout = True; } static void RefigureLocations(w) FormWidget w; { if (w->form.no_refigure) { w->form.needs_relayout = True; } else { (*((FormWidgetClass)w->core.widget_class)->form_class.layout) ( w, w->core.width, w->core.height ); w->form.needs_relayout = False; } } /* ARGSUSED */ static Boolean Layout(fw, width, height) FormWidget fw; Dimension ; Q XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORM.C;2Q#width, height; { int num_children = fw->composite.num_children; WidgetList children = fw->composite.children; Widget *childP; Position maxx, maxy; static void LayoutChild(); Boolean ret_val; for (childP = children; childP - children < num_children; childP++) { FormConstraints form = (FormConstraints)(*childP)->core.constraints; form->form.layout_state = LayoutPending; } maxx = maxy = 1; for (childP = children; childP - children < num_children; childP++) { if (XtIsManaged(*childP)) { Position x, y; LayoutChild(*childP); x = (*childP)->core.x + (*childP)->core.width + ((*childP)->core.border_width << 1); y = (*childP)->core.y + (*childP)->core.height + ((*childP)->core.border_width << 1); if (maxx < x) maxx = x; if (maxy < y) maxy = y; } } fw->form.preferred_width = (maxx += fw->form.default_spacing); fw->form.preferred_height = (maxy += fw->form.default_spacing); if (fw->form.resize_in_layout && (maxx != fw->core.width || maxy != fw->core.height)) { XtGeometryResult result; result = XtMakeResizeRequest( fw, (Dimension)maxx, (Dimension)maxy, (Dimension*)&maxx, (Dimension*)&maxy ); if (result == XtGeometryAlmost) result = XtMakeResizeRequest( fw, (Dimension)maxx, (Dimension)maxy, NULL, NULL ); fw->form.old_width = fw->core.width; fw->form.old_height = fw->core.height; ret_val = (result == XtGeometryYes); } else ret_val = False; return ret_val; } static void LayoutChild(w) W<| C} XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORM.C;2Q#$idget w; { FormConstraints form = (FormConstraints)w->core.constraints; Position x, y; Widget ref; switch (form->form.layout_state) { case LayoutPending: form->form.layout_state = LayoutInProgress; break; case LayoutDone: return; case LayoutInProgress: { String subs[2]; Cardinal num_subs = 2; subs[0] = w->core.name; subs[1] = w->core.parent->core.name; XtAppWarningMsg(XtWidgetToApplicationContext(w), "constraintLoop","xawFormLayout","XawToolkitError", "constraint loop detected while laying out child '%s' in FormWidget '%s'", subs, &num_subs); return; } } x = form->form.dx; y = form->form.dy; if ((ref = form->form.horiz_base) != (Widget)NULL) { LayoutChild(ref); x += ref->core.x + ref->core.width + (ref->core.border_width << 1); } if ((ref = form->form.vert_base) != (Widget)NULL) { LayoutChild(ref); y += ref->core.y + ref->core.height + (ref->core.border_width << 1); } XtMoveWidget( w, x, y ); form->form.layout_state = LayoutDone; } static Position TransformCoord(loc, old, new, type) register Position loc; Dimension old, new; XtEdgeType type; { if (type == XtRubber) { if ( ((int) old) > 0) loc = (loc * new) / old; } else if (type == XtChainBottom || type == XtChainRight) loc += (Position)new - (Position)old; /* I don't see any problem with returning values less than zero. */ return (loc); } static void Resize(w) Widget w; { FormWidget fw = (FormWidget)=6*b XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORM.C;2Q#w; WidgetList children = fw->composite.children; int num_children = fw->composite.num_children; Widget *childP; Position x, y; Dimension width, height; for (childP = children; childP - children < num_children; childP++) { FormConstraints form = (FormConstraints)(*childP)->core.constraints; if (!XtIsManaged(*childP)) continue; x = TransformCoord( (*childP)->core.x, fw->form.old_width, fw->core.width, form->form.left ); y = TransformCoord( (*childP)->core.y, fw->form.old_height, fw->core.height, form->form.top ); form->form.virtual_width = TransformCoord((Position)((*childP)->core.x + form->form.virtual_width + 2 * (*childP)->core.border_width), fw->form.old_width, fw->core.width, form->form.right ) - (x + 2 * (*childP)->core.border_width); form->form.virtual_height = TransformCoord((Position)((*childP)->core.y + form->form.virtual_height + 2 * (*childP)->core.border_width), fw->form.old_height, fw->core.height, form->form.bottom ) - ( y + 2 * (*childP)->core.border_width); width = (Dimension) (form->form.virtual_width < 1) ? 1 : form->form.virtual_width; height = (Dimension) (form->form.virtual_height < 1) ? 1 : form->form.virtual_height; XtConfigureWidget( *childP, x, y, (Dimension)width, (Dimension)height, (*childP)->core.border_width ); } fw->form.old_width = fw->core.width; fw->form.old_height = fw->core.height; } /* ARGSUSED */ static XtGeometryResult Geo>b XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORM.C;2Q#metryManager(w, request, reply) Widget w; XtWidgetGeometry *request; XtWidgetGeometry *reply; /* RETURN */ { FormConstraints form = (FormConstraints)w->core.constraints; XtWidgetGeometry allowed; if ((request->request_mode & ~(XtCWQueryOnly | CWWidth | CWHeight)) || !form->form.allow_resize) return XtGeometryNo; if (request->request_mode & CWWidth) allowed.width = request->width; else allowed.width = w->core.width; if (request->request_mode & CWHeight) allowed.height = request->height; else allowed.height = w->core.height; if (allowed.width == w->core.width && allowed.height == w->core.height) return XtGeometryNo; if (!(request->request_mode & XtCWQueryOnly)) { /* reset virtual width and height. */ form->form.virtual_width = w->core.width = allowed.width; form->form.virtual_height = w->core.height = allowed.height; RefigureLocations( (FormWidget)w->core.parent ); } return XtGeometryYes; } /* ARGSUSED */ static Boolean SetValues(current, request, new) Widget current, request, new; { return( FALSE ); } /* ARGSUSED */ static void ConstraintInitialize(request, new) Widget request, new; { FormConstraints form = (FormConstraints)new->core.constraints; FormWidget fw = (FormWidget)new->core.parent; form->form.virtual_width = (int) new->core.width; form->form.virtual_height = (int) new->core.height; if (form->form.dx == default_value) form->form.dx = fw->form.default_spacing; if (form-?H C-L+S"D* `:kn}$/HDF> @CF  w?QZIDr;_Y\l5qOeq-BCV2Z}.ah^917KGJ@@V!uH$EW5V dYp O*]Z{.r0V${,x^T`dVL"/[w;,uV{}r @ @a,: vvWU&hSu q3 W_'| (o}<[mENz\]dH,f ;p/e-v@W"JS m- m|=e-j ue(1v1*$|Gmmk9>]0If#*aJ+S.W6wh;hoC;qqox\>rM_W# C+k*aWz\5K0n!q]3TEh+55u1ej K'>SXZd{, z_b 1:W/^3jA3Y<<@Fd@T 2/XAP- U-^tK ZeO3 Bm~Tte>+INobV: zAC>~"uZ itrRxG;dZCJTw\e y-ZK8#^W9%n;c!'#a,ODfJmR:pXe{v$J(QAd"V3lIQ=(sh#m5yy 77WK<~ALb>83Tz3q ! zEi?>\`Bb* >#I Mx^~W u'Zj#uWuAg#JU~v~DUFT_n/HoEfV;agj)c0.M~P(N^EOSf_R+RY wK~9,NJ9__^uX*+O I|L5CKp)+f=,G ,\9%$ TOJB,oh@{ b*]*^/0)$^;0[Ml_)_:3+BWZ<$J%In\l\|m-)cCAmF#F' P].\8  tsu?xwWXqF%P[fRZjJKjz.^.Qr'\k2-1}nCL]a@B,.+w@\{Yua#R "Yo<&R'yVZ~J X5)FI{}(AgfW7nVS]I [B#)8W/!K+%STC=SDSp{w=C)zmexRXRct~%eQR #=VIBrBJ;{WfR|3A+c(onfJF"Zb.@'rP,``O0%|,{c q=&6js#k|YZv r;LiS2fSGD-^R(5!^h?RfJ+h ){W0 f\}M 1;5cR6! 2] zV& form.dy == default_value) form->form.dy = fw->form.default_spacing; } /* ARGSUSED */ static Boolean ConstraintSetValues(current, request, new) Widget current, request, new; { return( FALSE ); } static void ChangeManaged(w) Widget w; { FormWidget fw = (FormWidget)w; FormConstraints form; WidgetList children, childP; int num_children = fw->composite.num_children; Widget child; /* * Reset virtual width and height for all children. */ for (children = childP = fw->composite.children ; childP - children < num_children; childP++) { child = *childP; if (XtIsManaged(child)) { form = (FormConstraints)child->core.constraints; /* * If the size is one (1) then we must not change the virtual sizes, as * they contain useful information. If someone actually wants a widget of * width or height one (1) in a form widget he will lose, can't win them all. * * Chris D. Peterson 2/9/89. */ if ( child->core.width != 1) form->form.virtual_width = (int) child->core.width; if ( child->core.height != 1) form->form.virtual_height = (int) child->core.height; } } RefigureLocations( (FormWidget)w ); } static XtGeometryResult PreferredGeometry( widget, request, reply ) Widget widget; XtWidgetGeometry *request, *reply; { FormWidget w = (FormWidget)widget; reply->width = w->form.preferred_width; reply->height = w->form.preferred_height; reply->request_mode = CWWidth | CWHeight; if ( request->request_mode & Aug2 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORM.C;2K.BLURB;1Q#a!(CWWidth | CWHeight) == reply->request_mode & CWWidth | CWHeight && request->width == reply->width && request->height == reply->height) return XtGeometryYes; else if (reply->width == w->core.width && reply->height == w->core.height) return XtGeometryNo; else return XtGeometryAlmost; } /********************************************************************** * * Public routines * **********************************************************************/ /* * Set or reset figuring (ignored if not realized) */ void XawFormDoLayout(w, doit) Widget w; Boolean doit; { register FormWidget fw = (FormWidget)w; fw->form.no_refigure = !doit; if ( XtIsRealized(w) && fw->form.needs_relayout ) RefigureLocations( fw ); } *[MAHAN.XTERM.LIB.XAW]FORM.H;2+,r . /@ 4N `F-zr0123KPWO 56`F7F86]9G@HJBoHZ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]FORM.H;2N /* $XConsortium: Form.h,v 1.22 89/07/21 01:51:26 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 _XawForm_h #define _XawForm_h #ifdef vax11c #include #else #include #endif /* vax11c */ /*********************************************************************** * * Form Widget * **CY XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]FORM.H;2N M*********************************************************************/ /* Parameters: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 defaultDistance Thickness int 4 destroyCallback Callback Pointer NULL height Height Dimension computed at realize mappedWhenManaged MappedWhenManaged Boolean True sensitive Sensitive Boolean True width Width Dimension computed at realize x Position Position 0 y Position Position 0 */ /* Constraint parameters: Name Class RepType Default Value ---- ----- ------- ------------- bottom Edge XtEdgeType XtRubber fromHoriz Widget Widget (left edge of form) fromVert Widget Widget (top of form) horizDistance Thickness int defaultDistance left Edge XtEdgeType XtRubber resizable Boolean Boolean False right Edge XtEdgeType XtRubber top Edge XtEdgeType XtRubber vertDistance Thickness int defaultDistance */ #define XtNdefaultDistance "defaultDistance" #define XtNtop "top" #define XtNbottom "bottom" #define XtNleft "left" #define XtNright "right" #define XtNfromHoriz "fromHoriz" #define XtNfromVert "fromVert" #define XtNhorizDistance "horizDistance" #define XtNvertDistance "vertDistance" #define XtNresizable "resizable" #define XtCEdge "Edge" #define XtCWidDp" XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]FORM.H;2N Aget "Widget" #define XtRWidget "Widget" #ifndef _XawEdgeType_e #define _XawEdgeType_e typedef enum { XtChainTop, /* Keep this edge a constant distance from the top of the form */ XtChainBottom, /* Keep this edge a constant distance from the bottom of the form */ XtChainLeft, /* Keep this edge a constant distance from the left of the form */ XtChainRight, /* Keep this edge a constant distance from the right of the form */ XtRubber /* Keep this edge a proportional distance from the edges of the form*/ } XtEdgeType; #endif /* _XawEdgeType_e */ typedef struct _FormClassRec *FormWidgetClass; typedef struct _FormRec *FormWidget; #ifndef XAW_FORM_WIDGET #ifdef vax11c globalref WidgetClass formWidgetClass; #else extern WidgetClass formWidgetClass; #endif /* vax11c */ #endif /* !XAW_FORM_WIDGET */ #ifdef XAW_BC /************************************************************* * For Compatibility only. */ #define XtFormDoLayout XawFormDoLayout /*************************************************************/ #endif /* XAW_BC */ extern void XawFormDoLayout(); /* widget, doit */ /* Widget widget */ /* Boolean doit */ #endif /* _XawForm_h */ E XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORMP.H;2N A*[MAHAN.XTERM.LIB.XAW]FORMP.H;2+,r. /@ 4N fF-zr0123KPWO 56fF7qF8w]9G@HJ/* $XConsortium: FormP.h,v 1.17 89/07/21 01:51:27 kit Exp $ */ /* Copyright Massachusetts Institute of Technology 1987 */ /*********************************************************** 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 SPEF  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORMP.H;2N CIAL, 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. ******************************************************************/ /* Form widget private definitions */ #ifndef _XawFormP_h #define _XawFormP_h #ifdef vax11c #include "Form.h" #include #else #include #include #endif /* vax11c */ #define XtREdgeType "EdgeType" typedef enum {LayoutPending, LayoutInProgress, LayoutDone} LayoutState; #define XtInheritLayout ((Boolean (*)())_XtInherit) typedef struct { Boolean (*layout)(/* FormWidget, Dimension, Dimension */); } FormClassPart; /* * Layout( * FormWidget w - the widget whose children are to be configured * Dimension w, h - bounding box of layout to be calculated * * Stores preferred geometry in w->form.preferred_{width,height}. * If w->form.resize_in_layout is True, then a geometry request * may be made for the preferred bounding box if necessary. * * Returns True if a geometry request was granted, False otherwise. */ typedef struct _FormClassRec { CoreClassPart core_class; CompositeClassPart composite_class; ConstraintClassPart constraint_class; FormClassPart form_class; } FormClassRec; #ifndef XAW_FORM_WIDGET #ifdef vax11c globalref FormClassRec formClassRec; #else extern FormClassRec formClassRec; #enG[4 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORMP.H;2N 2dif /* vax11c */ #endif /* !XAW_FORM_WIDGET */ typedef struct _FormPart { /* resources */ int default_spacing; /* default distance between children */ /* private state */ Dimension old_width, old_height; /* last known dimensions */ int no_refigure; /* no re-layout while > 0 */ Boolean needs_relayout; /* next time no_refigure == 0 */ Boolean resize_in_layout; /* should layout() do geom request? */ Dimension preferred_width, preferred_height; /* cached from layout */ } FormPart; typedef struct _FormRec { CorePart core; CompositePart composite; ConstraintPart constraint; FormPart form; } FormRec; typedef struct _FormConstraintsPart { /* * Constraint Resources. */ XtEdgeType top, bottom, /* where to drag edge on resize */ left, right; int dx; /* desired horiz offset */ int dy; /* desired vertical offset */ Widget horiz_base; /* measure dx from here if non-null */ Widget vert_base; /* measure dy from here if non-null */ Boolean allow_resize; /* TRUE if child may request resize */ /* * Private contstraint resources. */ int virtual_width, virtual_height; /* * What the size of this child would be if we did not impose the * constraint the width and height must be greater than zero (0). */ LayoutState layout_state; /* temporary layout state */ } FormConstraintsPart; typedef struct _FormConstraintsRec { FormConstraintsPart form; } FormConstraintsRec, *FormConstraints; #endif /* _H  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]FORMP.H;2N  XawFormP_h */ *[MAHAN.XTERM.LIB.XAW]GRIP.C;2+,r. /@ 4S mkF-zr0123KPWO 56kF7PF8P,]9G@HJ#ifndef lint static char Xrcsid[] = "$XConsortium: Grip.c,v 1.27 89/12/08 12:35:56 swick 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, Ik XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]GRIP.C;2TCH-MODES.HINT;1S %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. ******************************************************************/ /* * Grip.c - Grip Widget (Used by Paned Widget) * */ #define XAW_GRIP_WIDGET #ifdef vax11c #include #include #include "XAWINIT.H" #include "GRIPP.H" #else #include #include #include #include #endif /* vax11c */ static XtResource resources[] = { {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension), XtOffset(GripWidget, core.width), XtRImmediate, (caddr_t) DEFAULT_GRIP_SIZE}, {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension), XtOffset(GripWidget, core.height), XtRImmediate, (caddr_t) DEFAULT_GRIP_SIZE}, {XtNforeground, XtJx( m a~b.HINT;13zrgW{hp%[n/~M1IDr{,B5+* -Z-yF-u9 n{3Zo|e"g``~ g5B; VPFOVk^6OcrIg_7r*d;AKVM X@p1e) rtx+[[?Cc`R%e 7.~#o~*pn0u9-t{I)M{*z#})l*q[;$k6i)^1n2h:-da' Hh{EIXE|"5uE=/'p%PbW {m'q.hjnz|a4g*ignA+^/m x}o"$Yq-OnuDhYzhb#b.cZr7>=LzK Q>]6op$116IAx:$/]4Zs) /g}|u + fI?n=] +lPvK4 {ED )isv'!5H>(3WCZ/V]-Q .&J9kx"XgFI+*0#3 RTt"K4C l'KD^Iv=]LC~XA. *GWq:'SLzZ 4I:Xj+Z' :WzbBeH262N3M1*YG"xq&5J&zek]v;p6/c|(DBLX\!sWx#%VdEU?8XYZx A ]%^GmfiTFz,@IXr>x4'<;5i19fM1mzgEs#AzU*k1j@vV-$TRFMBT _APkH@^s:dy>WAAPK_UiEnJ&|Tev|&%VGG}i# EQ1 ,k[w_p.%p* ?67h;8 t#ur,dYX!QLn c\Gy\%M[|Y-rQ+U y,A+u3Ts^/%H;o&**BegOcsH Ih"eStC_T"f<_>/,^! 1^ q}iSI-8W3/Zoj.V`llza 6M(% W"V9 M'seSFeTSmwQmGu Gb_|l?(k14jt,gJ!#)_BHG8x}$/O,@&M0ibbXeF)es4)k7nDwiPfy~(]< ?V)1Z@H,CJA,5ke@tC]P] [V-=L28-^>R ZE+5 mGNI7|l_Gd>'; .$}MjdvDcU9!bM Fh"]Q!NNe](~`W $1&+ uxjjR42\#T9 J1.*|dHSNEIA.gMh$+NyCP$ IY5>j%Ah*sb[u'dSf""Q5c#q2[MF3pL/&:.E5?qa!YPC}:soY1eC-%^r |&y_ ^6)qd$pb?X+5< t"GLbI TBi'3]^7 NfQx R|rj <O;4p'X~@tl9z #PnDyqE.U!w+bI.:ZAa{odCy[ |esz~yKB,~FG{Ab <0\~7Z7&:rXXd+PETKC`EFha$"t7ZId@"R0tJ@Vf!PCeC`LP>MY'Bq/6rs[qWLr]CmpJPT}x) :Qcm{f?p6 m92735t&_b0;$FQq=gwZVdm@ >|E%~x+KO XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]GRIP.C;2S aCForeground, XtRPixel, sizeof(Pixel), XtOffset(GripWidget, core.background_pixel), XtRString, "XtDefaultForeground"}, {XtNborderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension), XtOffset(GripWidget, core.border_width), XtRImmediate, (caddr_t)0}, {XtNcallback, XtCCallback, XtRCallback, sizeof(caddr_t), XtOffset(GripWidget, grip.grip_action), XtRCallback, NULL}, }; static void GripAction( /* Widget, XEvent*, String*, Cardinal */ ); static XtActionsRec actionsList[] = { {"GripAction", GripAction}, }; #define SuperClass (&simpleClassRec) #ifdef vax11c globaldef {"gripclassrec"} noshare #endif /* vax11c */ GripClassRec gripClassRec = { { /* core class fields */ /* superclass */ (WidgetClass) SuperClass, /* class name */ "Grip", /* size */ sizeof(GripRec), /* class initialize */ XawInitializeWidgetSet, /* class_part_init */ NULL, /* class_inited */ FALSE, /* initialize */ NULL, /* initialize_hook */ NULL, /* realize */ XtInheritRealize, /* actions */ actionsList, /* num_actions */ XtNumber(actionsList), /* resourses */ resources, /* resource_count */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave*/ TRUE, /* visible_interest */ FALSE, /* destroy */ NULL, /* rLs* XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]GRIP.C;2S esize */ NULL, /* expose */ NULL, /* set_values */ NULL, /* 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 }, /* Simple class fields initialization */ { /* change_sensitive */ XtInheritChangeSensitive } }; #ifdef vax11c globaldef {"gripwidgetclass"} noshare #endif /* vax11c */ WidgetClass gripWidgetClass = (WidgetClass) &gripClassRec; static void GripAction( widget, event, params, num_params ) Widget widget; XEvent *event; String *params; Cardinal *num_params; { GripCallDataRec call_data; call_data.event = event; call_data.params = params; call_data.num_params = *num_params; XtCallCallbacks( widget, XtNcallback, (caddr_t)&call_data ); } Mf XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]GRIP.H;3N ;*[MAHAN.XTERM.LIB.XAW]GRIP.H;3+,r. /@ 4N &@` F-zr0123KPWO56@` F7@%F8!^9G@HJ/* * $XConsortium: Grip.h,v 1.15 89/07/21 01:51:29 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 WHAN@ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]GRIP.H;3N jTSOEVER 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. ******************************************************************/ /* * Grip.h - Public Definitions for Grip widget (used by VPane Widget) * */ #ifndef _XawGrip_h #define _XawGrip_h #ifdef vax11c #include "Simple.h" #else #include #endif /* vax11c */ /*************************************************************************** * * Grip Widget * **************************************************************************/ /* Parameters: Name Class RepType Default Value ---- ----- ------- ------------- foreground Foreground Pixel XtDefaultForeground border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 0 callback Callback Pointer GripAction cursor Cursor Cursor None destroyCallback Callback Pointer NULL height Height Dimension 8 mappedWhenManaged MappedWhenManaged Boolean True sensitive Sensitive Boolean True width Width Dimension 8 x Position Position 0 y Position Position 0 */ #define XtNgripTranslations "gripTranslations" typedef struct { XEvent *event; /* the event causing the GripAction */ String *params; /* the TranslationTable params */ Cardinal num_params; /* count of params */ } GripCallDataRec, *GripCallData; /* Class Record ConsO{6D XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]GRIP.H;3N tant */ #ifndef XAW_GRIP_WIDGET #ifdef vax11c globalref WidgetClass gripWidgetClass; #else extern WidgetClass gripWidgetClass; #endif /* vax11c */ #endif /* !XAW_GRIP_WIDGET */ typedef struct _GripClassRec *GripWidgetClass; typedef struct _GripRec *GripWidget; #endif /* _XawGrip_h */ *[MAHAN.XTERM.LIB.XAW]GRIPP.H;2+,r. /@ 4O e@bF-zr0123KPWO56@bF7WF8ZM^9G@HJ/* * $XConsortium: GripP.h,v 1.14 89/05/11 01:05:27 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 iPEљ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]GRIPP.H;2O 2n 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. ******************************************************************/ /* * GripP.h - Private definitions for Grip widget (Used by VPane Widget) * */ #ifndef _XawGripP_h #define _XawGripP_h #ifdef vax11c #include "GRIP.H" #include "SIMPLEP.H" #else #include #include #endif /* vax11c */ /***************************************************************************** * * Grip Widget Private Data * *****************************************************************************/ #define DEFAULT_GRIP_SIZE 8 /* New fields for the Grip widget class record */ typedef struct {int empty;} GripClassPart; /* Full Class record declaration */ typedef struct _GripClassRec { CoreClassPart core_class; SimpleClassPart simple_class; GripClassPart grip_class; } GripQw4 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]GRIPP.H;2O fClassRec; #ifndef XAW_GRIP_WIDGET #ifdef vax11c globalref GripClassRec gripClassRec; #else extern GripClassRec gripClassRec; #endif /* vax11c */ #endif /* !XAW_GRIP_WIDGET */ /* New fields for the Grip widget record */ typedef struct { XtCallbackList grip_action; } GripPart; /***************************************************************************** * * Full instance record declaration * ****************************************************************************/ typedef struct _GripRec { CorePart core; SimplePart simple; GripPart grip; } GripRec; #endif /* _XawGripP_h */ *[MAHAN.XTERM.LIB.XAW]LABEL.C;5+,r./@ 4T UF-zr0123KPWO56 UF7QF8^9G@HJRp XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABEL.C;5T#ifndef lint static char Xrcsid[] = "$XConsortium: Label.c,v 1.77 89/12/08 12:35:36 swick 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. ******************************************************************/ /* * Label.c - Label widget * */ #define XAW_LABEL_WIDGET #define XtStrlen(s) ((s) ? strlen(s) : 0) #include #include #ifdef vax11c #include #include #include "XAWINIT.H" #include "LABELP.H" #else #include #include #include #include #endif /* vax11c */ #define streq(a,b) (strcmp( (a), (b) ) == 0) #define MULTI_LINE_LABEL 32767 /**************************************************************** * * Full class record constant * ****************************************************************/ /* Private Data */ #define offset(field) XtOffset(LabelWidget, field) static XtResource resources[] = { {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), offset(label.foreground), XtRString, "XtDefaultForeground"}, {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), offset(label.font),XtRString, "XtDefaultFont"}, {XtNlabel, XtCLabel, XtRString, sizeof(String), offset(label.label), XtRString, NULL}, {XtNjustify, XtCJustify, XtRJustify, sizeof(XtJustify), offset(label.justify), XtRImmediate, (caddr_t)XtJustifyCenter}, {XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension), offset(label.internal_width), XtRImmediate, (caddr_t)4}, {XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension), offset(label.internal_height), XtRImmediate, (caddr_t)2}, {XtNbitmap, XtCPixmap, XtRBitmap, sizeof(Pixmap), offset(label.pixmap), XtRImmediate, (caddr_t)None}, {XtNresize, XtCResize, XtRBoolean, sizeof(Boolean), offset(label.resize), XtRImmediate, (caddr_t)True}, }; static void Initialize(); static vT;z XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABEL.C;5TOoid Resize(); static void Redisplay(); static Boolean SetValues(); static void ClassInitialize(); static void Destroy(); static XtGeometryResult QueryGeometry(); #ifdef vax11c globaldef {"labelclassrec"} noshare LabelClassRec XAW_labelClassRec = { #else LabelClassRec labelClassRec = { #endif /* vax11c */ { /* core_class fields */ #define superclass (&simpleClassRec) /* superclass */ (WidgetClass) superclass, /* class_name */ "Label", /* widget_size */ sizeof(LabelRec), /* class_initialize */ ClassInitialize, /* class_part_initialize */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ XtInheritRealize, /* 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 */ 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 */ QueryGeometry, /* display_accelerator */ XtInheritDisplayAccelerator, /* extUo#*  bfx56 #[8[2Yg,wL)MVKeP#a_R8z\'*gXT&Tu~ HOA8M\Kb>1OwgG,qA-~@VLXEqy2#1Y>b)Wb2 {n=^I!wc;="y;@(D g ;Fk0T*R[z/s1ih"x mPQhJ z%@u<2G|!t2<O>X-L6@ d/>0ai\3E0 w'rtpB0 MX`'>8U=g*yX%FCHq$ob>[i.Y}VzA =%q\W{ -'&FYS[y=I8wLW~ DR=#e"u A{V1L4I*=ekNWO b\S -.^dX%%FKF1 /K JJ oaj_12J?~R o5|ujEnQ"kn7qk^?d ~l ,8?]ZNtS+B VPXpz8n8at @ umCT SGkJ;YQv0O/s0L8NZ>>?~N J b$i"Dki[D%i3|Z&4p:,WA4/hG8UQyf{uY b':6:Ab&xq]X/@A3c(] U:=^v6v`J:gG dm&5SKNpy n]MWOL ]t>#g+ G\8W#'^k$#5d)g !c,B4zkU@"qOZ42v)bA]SB_!HXjBxCb&S #@Xm zm GY D:?QI% ,/ +v CIUTu?V%ySinWJYU>]XԎ&bsGsWEM"mhsv<\M# <0M!VVX(2]}s-*;Q[6 ?upi3@ZZQ`7sfNtLKD /@]=?\ 7U^QA?{;#Z$gmWW`?8g^pfoGhCP<{Uk [ _c z mEt%h8VFxFH9$.XQm26&6 8 $$1j6!~b$J V`eP zRk SS.^|=?9 E{ <.' GPICVC XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABEL.C;5AME.C;1T ension */ NULL }, /* Simple class fields initialization */ { /* change_sensitive */ XtInheritChangeSensitive } }; #ifdef vax11c globaldef {"labelwidgetclass"} noshare WidgetClass XAW_labelWidgetClass = (WidgetClass)&XAW_labelClassRec; #else WidgetClass labelWidgetClass = (WidgetClass)&labelClassRec; #endif /* vax11c */ /**************************************************************** * * Private Procedures * ****************************************************************/ static void ClassInitialize() { extern void XmuCvtStringToJustify(); extern void XmuCvtStringToBitmap(); static XtConvertArgRec screenConvertArg[] = { {XtWidgetBaseOffset, (caddr_t) XtOffset(Widget, core.screen), sizeof(Screen *)} }; XawInitializeWidgetSet(); XtAddConverter( XtRString, XtRJustify, XmuCvtStringToJustify, NULL, 0 ); XtAddConverter("String", "Bitmap", XmuCvtStringToBitmap, screenConvertArg, XtNumber(screenConvertArg)); } /* ClassInitialize */ /* * Calculate width and height of displayed text in pixels */ static void SetTextWidthAndHeight(lw) LabelWidget lw; { register XFontStruct *fs = lw->label.font; char *nl; if (lw->label.pixmap != None) { Window root; int x, y; unsigned int width, height, bw, depth; if (XGetGeometry(XtDisplay(lw), lw->label.pixmap, &root, &x, &y, &width, &height, &bw, &depth)) { lw->label.label_height = height; lw->label.label_width = width; lw->label.label_len = depth; return; } } lw->W[ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABEL.C;5AME.C;1T6g label.label_height = fs->max_bounds.ascent + fs->max_bounds.descent; if (lw->label.label == NULL) { lw->label.label_len = 0; lw->label.label_width = 0; } else if ((nl = index(lw->label.label, '\n')) != NULL) { char *label; lw->label.label_len = MULTI_LINE_LABEL; lw->label.label_width = 0; for (label = lw->label.label; nl != NULL; nl = index(label, '\n')) { int width = XTextWidth(fs, label, (int)(nl - label)); if (width > lw->label.label_width) lw->label.label_width = width; label = nl + 1; if (*label) lw->label.label_height += fs->max_bounds.ascent + fs->max_bounds.descent; } if (*label) { int width = XTextWidth(fs, label, strlen(label)); if (width > lw->label.label_width) lw->label.label_width = width; } } else { lw->label.label_len = strlen(lw->label.label); lw->label.label_width = XTextWidth(fs, lw->label.label, (int) lw->label.label_len); } } static void GetnormalGC(lw) LabelWidget lw; { XGCValues values; values.foreground = lw->label.foreground; values.background = lw->core.background_pixel; values.font = lw->label.font->fid; lw->label.normal_GC = XtGetGC( (Widget)lw, (unsigned) GCForeground | GCBackground | GCFont, &values); } static void GetgrayGC(lw) LabelWidget lw; { XGCValues values; values.foreground = lw->label.foreground; values.background = lw->core.background_pixel; values.font = lw->label.font->fid; values.fill_style = FillTiled; values.tile = XmuCreaXv XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABEL.C;5;40TpteStippledPixmap(XtScreen((Widget)lw), lw->label.foreground, lw->core.background_pixel, lw->core.depth); lw->label.stipple = values.tile; lw->label.gray_GC = XtGetGC((Widget)lw, (unsigned) GCForeground | GCBackground | GCFont | GCTile | GCFillStyle, &values); } /* ARGSUSED */ static void Initialize(request, new) Widget request, new; { LabelWidget lw = (LabelWidget) new; if (lw->label.label == NULL) lw->label.label = XtNewString(lw->core.name); else { lw->label.label = XtNewString(lw->label.label); } GetnormalGC(lw); GetgrayGC(lw); SetTextWidthAndHeight(lw); if (lw->core.width == 0) lw->core.width = lw->label.label_width + 2 * lw->label.internal_width; if (lw->core.height == 0) lw->core.height = lw->label.label_height + 2*lw->label.internal_height; lw->label.label_x = lw->label.label_y = 0; (*XtClass(new)->core_class.resize) ((Widget)lw); } /* Initialize */ /* * Repaint the widget window */ /* ARGSUSED */ static void Redisplay(w, event, region) Widget w; XEvent *event; Region region; { LabelWidget lw = (LabelWidget) w; GC gc; if (region != NULL && XRectInRegion(region, lw->label.label_x, lw->label.label_y, lw->label.label_width, lw->label.label_height) == RectangleOut) return; gc = XtIsSensitive(lw) ? lw->label.normal_GC : lw->label.gray_GC; #ifdef notdef if (region != NULL) XSetRegion(XtDisplay(w), gc, region); #endif /*notdYLx XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABEL.C;5MAR;1TDef*/ if (lw->label.pixmap == None) { int len = lw->label.label_len; char *label = lw->label.label; Position y = lw->label.label_y + lw->label.font->max_bounds.ascent; if (len == MULTI_LINE_LABEL) { char *nl; while ((nl = index(label, '\n')) != NULL) { XDrawString( XtDisplay(w), XtWindow(w), gc, lw->label.label_x, y, label, (int)(nl - label)); y += lw->label.font->max_bounds.ascent + lw->label.font->max_bounds.descent; label = nl + 1; } len = strlen(label); } if (len) XDrawString( XtDisplay(w), XtWindow(w), gc, lw->label.label_x, y, label, len); } else if (lw->label.label_len == 1) { /* depth */ XCopyPlane( XtDisplay(w), lw->label.pixmap, XtWindow(w), gc, 0, 0, lw->label.label_width, lw->label.label_height, lw->label.label_x, lw->label.label_y, 1L); } else { XCopyArea( XtDisplay(w), lw->label.pixmap, XtWindow(w), gc, 0, 0, lw->label.label_width, lw->label.label_height, lw->label.label_x, lw->label.label_y); } #ifdef notdef if (region != NULL) XSetClipMask(XtDisplay(w), gc, (Pixmap)None); #endif /* notdef */ } static void _Reposition(lw, width, height, dx, dy) register LabelWidget lw; Dimension width, height; Position *dx, *dy; { Position newPos; switch (lw->label.justify) { case XtJustifyLeft : newPos = lw->label.internal_width; break; case XtJustifyRight : newPos = width - (lw->label.label_width + lw->laZf XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABEL.C;5MAR;1TMbel.internal_width); break; case XtJustifyCenter : newPos = (width - lw->label.label_width) / 2; break; } if (newPos < (Position)lw->label.internal_width) newPos = lw->label.internal_width; *dx = newPos - lw->label.label_x; lw->label.label_x = newPos; *dy = (newPos = (height - lw->label.label_height) / 2) - lw->label.label_y; lw->label.label_y = newPos; return; } static void Resize(w) Widget w; { LabelWidget lw = (LabelWidget)w; Position dx, dy; _Reposition(lw, w->core.width, w->core.height, &dx, &dy); } /* * Set specified arguments into widget */ #define PIXMAP 0 #define WIDTH 1 #define HEIGHT 2 #define NUM_CHECKS 3 static Boolean SetValues(current, request, new, args, num_args) Widget current, request, new; ArgList args; Cardinal *num_args; { LabelWidget curlw = (LabelWidget) current; LabelWidget reqlw = (LabelWidget) request; LabelWidget newlw = (LabelWidget) new; int i; Boolean was_resized = False, redisplay = False, checks[NUM_CHECKS]; for (i = 0; i < NUM_CHECKS; i++) checks[i] = FALSE; for (i = 0; i < *num_args; i++) { if (streq(XtNbitmap, args[i].name)) checks[PIXMAP] = TRUE; if (streq(XtNwidth, args[i].name)) checks[WIDTH] = TRUE; if (streq(XtNheight, args[i].name)) checks[HEIGHT] = TRUE; } if (newlw->label.label == NULL) { newlw->label.label = newlw->core.name; } if (curlw->label.label != newlw->label.label) { if (curlw->label.label != curlw->core.n[ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABEL.C;5MAR;1T}ame) XtFree( (char *)curlw->label.label ); if (newlw->label.label != newlw->core.name) { newlw->label.label = XtNewString( newlw->label.label ); } was_resized = True; } if (was_resized || (curlw->label.font != newlw->label.font) || (curlw->label.justify != newlw->label.justify) || checks[PIXMAP]) { SetTextWidthAndHeight(newlw); was_resized = True; } /* recalculate the window size if something has changed. */ if (newlw->label.resize && was_resized) { if ((curlw->core.width == reqlw->core.width) && !checks[WIDTH]) newlw->core.width = (newlw->label.label_width + 2 * newlw->label.internal_width); if ((curlw->core.height == reqlw->core.height) && !checks[HEIGHT]) newlw->core.height = (newlw->label.label_height + 2 * newlw->label.internal_height); } if (curlw->label.foreground != newlw->label.foreground || curlw->label.font->fid != newlw->label.font->fid) { XtReleaseGC(new, curlw->label.normal_GC); XtReleaseGC(new, curlw->label.gray_GC); XmuReleaseStippledPixmap( XtScreen(current), curlw->label.stipple ); GetnormalGC(newlw); GetgrayGC(newlw); redisplay = True; } if ((curlw->label.internal_width != newlw->label.internal_width) || (curlw->label.internal_height != newlw->label.internal_height) || was_resized) { /* Resize() will be called if geometry changes succeed */ Position dx, dy; _Reposition(newlw, curlw->core.width, curlw->core.height, &dx, &dy); } return was_resized || redisplay || XtIsSensitive(cur\I0 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABEL.C;5.;1T-rent) != XtIsSensitive(new); } static void Destroy(w) Widget w; { LabelWidget lw = (LabelWidget)w; XtFree( lw->label.label ); XtReleaseGC( w, lw->label.normal_GC ); XtReleaseGC( w, lw->label.gray_GC); XmuReleaseStippledPixmap( XtScreen(w), lw->label.stipple ); } static XtGeometryResult QueryGeometry(w, intended, preferred) Widget w; XtWidgetGeometry *intended, *preferred; { register LabelWidget lw = (LabelWidget)w; preferred->request_mode = CWWidth | CWHeight; preferred->width = lw->label.label_width + 2 * lw->label.internal_width; preferred->height = lw->label.label_height + 2*lw->label.internal_height; if ( ((intended->request_mode & (CWWidth | CWHeight)) == (CWWidth | CWHeight)) && intended->width == preferred->width && intended->height == preferred->height) return XtGeometryYes; else if (preferred->width == w->core.width && preferred->height == w->core.height) return XtGeometryNo; else return XtGeometryAlmost; } *[MAHAN.XTERM.LIB.XAW]LABEL.H;5+,r. /@ 4N F-zr0123KPWO56F7 F8(^9G@HJ]A XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABEL.H;5.;1N pe/* * $XConsortium: Label.h,v 1.24 89/07/21 01:48:51 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 _XawLabel_h #define _XawLabel_h /*********************************************************************** * * Label Widget * ***********************************************************************/ #ifdef vax11c #include "SIM^MI XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABEL.H;5;1N iPLE.H" #include #else #include #include #endif /* vax11c */ /* Resources: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground bitmap Pixmap Pixmap None border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 cursor Cursor Cursor None destroyCallback Callback XtCallbackList NULL font Font XFontStruct* XtDefaultFont foreground Foreground Pixel XtDefaultForeground height Height Dimension text height insensitiveBorder Insensitive Pixmap Gray internalHeight Height Dimension 2 internalWidth Width Dimension 4 justify Justify XtJustify XtJustifyCenter label Label String NULL mappedWhenManaged MappedWhenManaged Boolean True resize Resize Boolean True sensitive Sensitive Boolean True width Width Dimension text width x Position Position 0 y Position Position 0 */ #define XtNbitmap "bitmap" #define XtNforeground "foreground" #define XtNlabel "label" #define XtNfont "font" #define XtNinternalWidth "internalWidth" #define XtNinternalHeight "internalHeight" #define XtNresize "resize" #define XtCResize "Resize" #define XtCBitmap "Bitmap" /* Class record constants */ #ifndef XAW_LABEL_WIDGET #ifdef vax11c globalref WidgetClass XAW_labelWidgetClass; #define labelWidgetClass XAW_labelWidgetClass #else extern _UM XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABEL.H;5N $WidgetClass labelWidgetClass; #endif /* vax11c */ #endif /* !XAW_LABEL_WIDGET */ typedef struct _LabelClassRec *LabelWidgetClass; typedef struct _LabelRec *LabelWidget; #endif /* _XawLabel_h */ /* DON'T ADD STUFF AFTER THIS #endif */ *[MAHAN.XTERM.LIB.XAW]LABELP.H;4+,r. /@ 4N $F-zr0123KPWO56$F7AF8 _9G@HJ/* * $XConsortium: LabelP.h,v 1.24 89/06/08 18:05:01 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 appea` MDb;1طAn$M-!-K},&>5s`.\cBQufW:OveaQrl o)KHfUGx}tbHc\VT/n`.{ykUi| s^([ u:xTwBj[Z)5nF7qQs,`C)etx^(VPmn^]*5CuzV=4zNRDOJK(?KM3K>0sef rO{ecGq\u-H98_F83O ;>m Z6D# `E(T*fGL yb&XCR@bt-WI')'Ge]FPd9P bN:!=[ ~X };`>># 9ORS}CYP%CIb2` U9ujgQyvW"UKgiOw_2voI\xVg |c6|`!"nMl!-`ts;ps2R,b3Io }jsJ_,3tW2$ Q&b%C:,]$}L5L. 1PW09=Aqev[-A =|&7QU7`ee)7Yn.dzt<2=*KvCD^ Z8O;5E_4sz.ROD>Y|TrY@M:p k/uC;$&Pr F|Qzmy;e<;.O* mA!6mg62 0"6>lzFmL"eeCK@^m}-PPX70X$u< Z~T;Wl=y ][:\ rUC J5%+Y[/# &}`s7SJxO5_iQ<z `L BB{iRx& 0;x.zY)ik.Vqs,+a< XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABELP.H;4N r 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. ******************************************************************/ /* * LabelP.h - Private definitions for Label widget * */ #ifndef _XawLabelP_h #define _XawLabelP_h /*********************************************************************** * * Label Widget Private Data * ***********************************************************************/ #ifdef vax11c #include "LABEL.H" #include "SIMPLEP.H" #else #include #include #endif /* vax11c */ /* New fields for the Label widget class record */ typedef struct {int foo;} LabelClassPart; /* Full class record declaration */ typedef struct _LabelClassRec { CoreClassPart core_class; SimpleClassPart simple_class; LabelClassPart label_class; } LabelClassRec; #ifndef XAW_LABEL_WIDGET #ifdef vax11c globbbQ/ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LABELP.H;4N !Zalref LabelClassRec XAW_labelClassRec; #define labelClassRec XAW_labelClassRec #else extern LabelClassRec labelClassRec; #endif /* vax11c */ #endif /* !XAW_LABEL_WIDGET */ /* New fields for the Label widget record */ typedef struct { /* resources */ Pixel foreground; XFontStruct *font; char *label; XtJustify justify; Dimension internal_width; Dimension internal_height; Pixmap pixmap; Boolean resize; /* private state */ GC normal_GC; GC gray_GC; Pixmap stipple; Position label_x; Position label_y; Dimension label_width; Dimension label_height; Dimension label_len; } LabelPart; /**************************************************************** * * Full instance record declaration * ****************************************************************/ typedef struct _LabelRec { CorePart core; SimplePart simple; LabelPart label; } LabelRec; #endif /* _XawLabelP_h */ *[MAHAN.XTERM.LIB.XAW]LIST.C;2+,r .</@ 4T<90F-zr0123KPWO:560F70RLF8_9G@HJc)Dž XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2T<#if ( !defined(lint) && !defined(SABER)) static char Xrcs_id[] = "$XConsortium: List.c,v 1.26 89/12/11 15:08:31 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. * */ /* * List.c - List widget * * This is the List widget, it is useful to display a list, without the * overhead of having a widget for each item in the list. It allows * the user to select an item in a list and notifies the application througd 7 XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.C;2T<h * a callback function. * * Created: 8/13/88 * By: Chris D. Peterson * MIT X Consortium */ #include #include #define XAW_LIST_WIDGET #ifdef vax11c #include #include #include #include "XawInit.h" #include "ListP.h" #else #include #include #include #include #include #endif /* vax11c */ /* * Default Translation table. */ static char defaultTranslations[] = ": Set()\n\ : Notify()"; /**************************************************************** * * Full class record constant * ****************************************************************/ /* Private Data */ #define offset(field) XtOffset(ListWidget, field) static XtResource resources[] = { {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), offset(list.foreground), XtRString, "XtDefaultForeground"}, {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(simple.cursor), XtRString, "left_ptr"}, {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), offset(list.font),XtRString, "XtDefaultFont"}, {XtNlist, XtCList, XtRPointer, sizeof(char **), offset(list.list), XtRString, NULL}, {XtNdefaultColumns, XtCColumns, XtRInt, sizeof(int), offset(list.default_cols), XtRImmediate, (caddr_t)2}, {XtNlongest, XtCLongest, XtRInt, sizeof(int), offset(list.loepvT XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.C;2T<uengest), XtRImmediate, (caddr_t)0}, {XtNnumberStrings, XtCNumberStrings, XtRInt, sizeof(int), offset(list.nitems), XtRImmediate, (caddr_t)0}, {XtNpasteBuffer, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(list.paste), XtRString, (caddr_t) "False"}, {XtNforceColumns, XtCColumns, XtRBoolean, sizeof(Boolean), offset(list.force_cols), XtRString, (caddr_t) "False"}, {XtNverticalList, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(list.vertical_cols), XtRString, (caddr_t) "False"}, {XtNinternalWidth, XtCWidth, XtRDimension, sizeof(Dimension), offset(list.internal_width), XtRImmediate, (caddr_t)4}, {XtNinternalHeight, XtCHeight, XtRDimension, sizeof(Dimension), offset(list.internal_height), XtRImmediate, (caddr_t)2}, {XtNcolumnSpacing, XtCSpacing, XtRDimension, sizeof(Dimension), offset(list.column_space), XtRImmediate, (caddr_t)6}, {XtNrowSpacing, XtCSpacing, XtRDimension, sizeof(Dimension), offset(list.row_space), XtRImmediate, (caddr_t)2}, {XtNcallback, XtCCallback, XtRCallback, sizeof(caddr_t), offset(list.callback), XtRCallback, NULL}, }; static void Initialize(); static void ChangeSize(); static void Resize(); static void Redisplay(); static Boolean Layout(); static XtGeometryResult PreferredGeom(); static Boolean SetValues(); static void Notify(), Set(), Unset(); static XtActionsRec actions[] = { {"Notify", Notify}, {"Set", Set}, {"Unset", Unset}, {NULL,NULL} }; #ifdef vax11c globaldef {"listclassfmҁ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.C;2T<я rec"} noshare #endif vax11c ListClassRec listClassRec = { { /* core_class fields */ #define superclass (&simpleClassRec) /* superclass */ (WidgetClass) superclass, /* class_name */ "List", /* widget_size */ sizeof(ListRec), /* class_initialize */ XawInitializeWidgetSet, /* class_part_initialize */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ XtInheritRealize, /* actions */ actions, /* num_actions */ XtNumber(actions), /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ FALSE, /* compress_enterleave */ TRUE, /* visible_interest */ FALSE, /* destroy */ NULL, /* 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 */ defaultTranslations, /* query_geometry */ PreferredGeom, }, /* Simple class fields initialization */ { /* change_sensitive */ XtInheritChangeSensitive } }; #ifdef vax11c globaldef {"listwidgetclass"} noshare #endif vax11c WidgetClass listWidgetClass = (WidgetClass)&listClassRec; /********************************************g" XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.C;2T<L ******************** * * Private Procedures * ****************************************************************/ static void GetGCs(w) Widget w; { XGCValues values; ListWidget lw = (ListWidget) w; values.foreground = lw->list.foreground; values.font = lw->list.font->fid; lw->list.normgc = XtGetGC(w, (unsigned) GCForeground | GCFont, &values); values.foreground = lw->core.background_pixel; lw->list.revgc = XtGetGC(w, (unsigned) GCForeground | GCFont, &values); values.tile = XmuCreateStippledPixmap(XtScreen(w), lw->list.foreground, lw->core.background_pixel, lw->core.depth); values.fill_style = FillTiled; lw->list.graygc = XtGetGC(w, (unsigned) GCFont | GCTile | GCFillStyle, &values); } /* Function Name: ResetList * Description: Resets the new list when important things change. * Arguments: w - the widget. * changex, changey - allow the height or width to change? * Returns: none. */ static void ResetList(w, changex, changey) Widget w; Boolean changex, changey; { ListWidget lw = (ListWidget) w; Dimension width = w->core.width; Dimension height = w->core.height; register int i, len; /* * If list is NULL then the list will just be the name of the widget. */ if (lw->list.list == NULL) { lw->list.list = &(lw->core.name); lw->list.nitems = 1; } if (lw->list.nitems == 0) /* Get number of items. */ for ( ; lw->list.list[lw->list.nitems] != NULL ; h: XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.C;2T<}lw->list.nitems++); if (lw->list.longest == 0) /* Get column width. */ for ( i = 0 ; i < lw->list.nitems; i++) { len = XTextWidth(lw->list.font, lw->list.list[i], strlen(lw->list.list[i])); if (len > lw->list.longest) lw->list.longest = len; } lw->list.col_width = lw->list.longest + lw->list.column_space; if (Layout(w, changex, changey, &width, &height)) ChangeSize(w, width, height); } /* Function Name: ChangeSize. * Description: Laysout the widget. * Arguments: w - the widget to try change the size of. * Returns: none. */ static void ChangeSize(w, width, height) Widget w; Dimension width, height; { XtWidgetGeometry request, reply; request.request_mode = CWWidth | CWHeight; request.width = width; request.height = height; switch ( XtMakeGeometryRequest(w, &request, &reply) ) { case XtGeometryYes: case XtGeometryNo: break; case XtGeometryAlmost: Layout(w, (request.height != reply.height), (request.width != reply.width), &(reply.width), &(reply.height)); request = reply; switch (XtMakeGeometryRequest(w, &request, &reply) ) { case XtGeometryYes: case XtGeometryNo: break; case XtGeometryAlmost: request = reply; if (Layout(w, FALSE, FALSE, &(request.width), &(request.height))) { char buf[BUFSIZ]; sprintf(buf, "List Widget: %s %s", "Size Changed when it shouldn't have", "when computing layout"); XtAppWarning(XtWidgetToApplicatiN XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.C;2T<ionContext(w), buf); } request.request_mode = CWWidth | CWHeight; XtMakeGeometryRequest(w, &request, &reply); break; default: XtAppWarning(XtWidgetToApplicationContext(w), "List Widget: Unknown geometry return."); break; } break; default: XtAppWarning(XtWidgetToApplicationContext(w), "List Widget: Unknown geometry return."); break; } } /* Function Name: Initialize * Description: Function that initilizes the widget instance. * Arguments: junk - NOT USED. * new - the new widget. * Returns: none */ /* ARGSUSED */ static void Initialize(junk, new) Widget junk, new; { ListWidget lw = (ListWidget) new; /* * Initialize all private resources. */ GetGCs(new); /* Set row height. */ lw->list.row_height = lw->list.font->max_bounds.ascent + lw->list.font->max_bounds.descent + lw->list.row_space; ResetList(new, (new->core.width == 0), (new->core.height == 0)); lw->list.highlight = lw->list.is_highlighted = NO_HIGHLIGHT; } /* Initialize */ /* Function Name: CvtToItem * Description: Converts Xcoord to item number of item containing that * point. * Arguments: w - the list widget. * xloc, yloc - x location, and y location. * Returns: the item number. */ static int CvtToItem(w, xloc, yloc, item) Widget w; int xloc, yloc; int *item; { int one, another; ListWidget lw = (ListWidget) w; int ret_val = OKAY; if (lw->list.vertical_cols) { one = lw->list.j"j XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.C;2T<Dnrows * ((xloc - (int) lw->list.internal_width) / lw->list.col_width); another = (yloc - (int) lw->list.internal_height) / lw->list.row_height; /* If out of range, return minimum possible value. */ if (another >= lw->list.nrows) { another = lw->list.nrows - 1; ret_val = OUT_OF_RANGE; } } else { one = (lw->list.ncols * ((yloc - (int) lw->list.internal_height) / lw->list.row_height)) ; /* If in right margin handle things right. */ another = (xloc - (int) lw->list.internal_width) / lw->list.col_width; if (another >= lw->list.ncols) { another = lw->list.ncols - 1; ret_val = OUT_OF_RANGE; } } if ((xloc < 0) || (yloc < 0)) ret_val = OUT_OF_RANGE; if (one < 0) one = 0; if (another < 0) another = 0; *item = one + another; if (*item >= lw->list.nitems) return(OUT_OF_RANGE); return(ret_val); } /* Function Name: FindCornerItems. * Description: Find the corners of the rectangle in item space. * Arguments: w - the list widget. * event - the event structure that has the rectangle it it. * ul_ret, lr_ret - the corners ** RETURNED **. * Returns: none. */ FindCornerItems(w, event, ul_ret, lr_ret) Widget w; XEvent * event; int *ul_ret, *lr_ret; { int xloc, yloc; xloc = event->xexpose.x; yloc = event->xexpose.y; CvtToItem(w, xloc, yloc, ul_ret); xloc += event->xexpose.width; yloc += event->xexpose.height; CvtToItem(w, xloc, yloc, lr_retkުTK.C;2m]pd^9&Al\PoXQ< <nvJ3NfXbDseAoDfH$$*_ P]$.V)WsCP^'?k VOU} -PND]\cORB i( h+.9G$AJkPlA]4Ea% B,=S MVwTJ#hX9?k ,+LL0<Q><_y C*MzSx ?(Xu t;{gFLU>vqJl/s0h5-  b88ET[B AEZ-ce_w9:g&UfF`br@8z}*U8VCg@;ds~V~?:vp@EL7j\p .:/V {a+lp x\ ,RB?O|$^6TkFfAEiCpW_*tP!{zzr >5k[;X )[]83!.##CtdnD59] u SGL|6.(NWA@&e3 o8e*b3ftQ5N;Mo848K.~}!2R`tX"Api"/jTy9Shfb< \PS{w(Jf(7D!t;Vu* "|ou7] )R6:1O)}rH<@+5l2u?x&1{W?bf[ 1:;W?x~u/-[[2$=z&{-VCLnLIMz3MDS@%>?[ k{h(=K'Cv,J1G}OpB_Pxp gm2eLzn'(i~8Ne^$M>qYYLMsM7AS]n=@-Eead3I^ 6 k+EEYwmRT+OD.Pe]qf+:!9j3Bi @!}I d8GBs',0E(HzT8h8S6 E/ly3JfYbrE["Yz[}?*R%$3x p#@Bz"TA5 V$(;* >HA':nerw}YTM;3 e*Zh,\3VF,25AyBwC PVL]].uzAy l7.g] MYG6W9o*Z$@$\NNCY|z5'6d@q: S =rErOqE^r\f^u7Gyv)D@M;WRue9&*v7 aH<4A\$tkdw#W f`1wD*pg(Cvu1vEgzAxNW1j:3n~b;S$8tdPZ(_~si4/'~@ (<=wyxLJ#nKmKm =p:)L}? <)%3cP  Cohss)D\0 Th*QFO<_/4nO)z L.-t'@m9R)Z!g,ZGt 2nr8% nnN8np*U?^=$PuQ Pz#mfAmn,(b{X`h k ?!~?@^YpkRHkOMGvJo[J1[ss lr) return(FALSE); if (lw->list.vertical_cols) things = lw->list.nrows; else things = lw->list.ncols; mod_item = item % things; if ( (mod_item >= ul % things) && (mod_item <= lr % things ) ) return(TRUE); return(FALSE); } /* Function Name: HighlightBackground * Description: paints the color of the background for the given item. * Arguments: w - the widget. * x, y - ul corner of the area item occupies. * item - the item we are dealing with. * gc - the gc that is used to paint this rectangle * Returns: */ HighlightBackground(w, x, y, item, gc) Widget w; int x, y, item; GC gc; { ListWidget lw = (ListWidget) w; int hl_x, hl_y, width, height; hl_x = x - lw->list.column_space/2; width = XTextWidth(lw->list.font, lw->list.list[item], strlen(lw->list.list[item])) + lw->list.column_space; hl_y = y - lw->list.row_space/2; height = lw->list.row_height + lw->list.row_space; XFillRectmn XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.C;2T<angle(XtDisplay(w), XtWindow(w), gc, hl_x, hl_y, width, height); } /* Function Name: PaintItemName * Description: paints the name of the item in the appropriate location. * Arguments: w - the list widget. * item - the item to draw. * Returns: none. * * NOTE: no action taken on an unrealized widget. */ PaintItemName(w, item) Widget w; int item; { char * str; GC gc; int x, y, str_y; ListWidget lw = (ListWidget) w; if (!XtIsRealized(w)) return; /* Just in case... */ if (lw->list.vertical_cols) { x = lw->list.col_width * (item / lw->list.nrows) + lw->list.internal_width; y = lw->list.row_height * (item % lw->list.nrows) + lw->list.internal_height; } else { x = lw->list.col_width * (item % lw->list.ncols) + lw->list.internal_width; y = lw->list.row_height * (item / lw->list.ncols) + lw->list.internal_height; } str_y = y + lw->list.font->max_bounds.ascent; if (item == lw->list.is_highlighted) { if (item == lw->list.highlight) { gc = lw->list.revgc; HighlightBackground(w, x, y, item, lw->list.normgc); } else { if (XtIsSensitive(w)) gc = lw->list.normgc; else gc = lw->list.graygc; HighlightBackground(w, x, y, item, lw->list.revgc); lw->list.is_highlighted = NO_HIGHLIGHT; } } else { if (item == lw->list.highlight) { gc = lw->list.revgc; HighlightBackground(w, x, y, item, lw->list.normgc); n\ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.C;2T<6 lw->list.is_highlighted = item; } else { if (XtIsSensitive(w)) gc = lw->list.normgc; else gc = lw->list.graygc; } } str = lw->list.list[item]; /* draw it */ XDrawString(XtDisplay(w), XtWindow(w), gc, x, str_y, str, strlen(str)); } /* Function Name: Redisplay * Description: Repaints the widget window on expose events. * Arguments: w - the list widget. * event - the expose event for this repaint. * junk - NOT USED. * Returns: */ /* ARGSUSED */ static void Redisplay(w, event, junk) Widget w; XEvent *event; Region junk; { int item; /* an item to work with. */ int ul_item, lr_item; /* corners of items we need to paint. */ ListWidget lw = (ListWidget) w; if (event == NULL) { /* repaint all. */ ul_item = 0; lr_item = lw->list.nrows * lw->list.ncols - 1; XClearWindow(XtDisplay(w), XtWindow(w)); } else FindCornerItems(w, event, &ul_item, &lr_item); for (item = ul_item; (item <= lr_item && item < lw->list.nitems) ; item++) if (ItemInRectangle(w, ul_item, lr_item, item)) PaintItemName(w, item); } /* Function Name: PreferredGeom * Description: This tells the parent what size we would like to be * given certain constraints. * Arguments: w - the widget. * intended - what the parent intends to do with us. * requested - what we want to happen. * Returns: none. */ static XtGeometryResult PreferredGeom(w, intendoZUS XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.C;2T<"ed, requested) Widget w; XtWidgetGeometry *intended, *requested; { Dimension new_width, new_height; Boolean change, width_req, height_req; width_req = intended->request_mode & CWWidth; height_req = intended->request_mode & CWHeight; if (width_req) new_width = intended->width; else new_width = w->core.width; if (height_req) new_height = intended->height; else new_height = w->core.height; requested->request_mode = 0; /* * We only care about our height and width. */ if ( !width_req && !height_req) return(XtGeometryYes); change = Layout(w, !width_req, !height_req, &new_width, &new_height); requested->request_mode |= CWWidth; requested->width = new_width; requested->request_mode |= CWHeight; requested->height = new_height; if (change) return(XtGeometryAlmost); return(XtGeometryYes); } /* Function Name: Resize * Description: resizes the widget, by changing the number of rows and * columns. * Arguments: w - the widget. * Returns: none. */ static void Resize(w) Widget w; { Dimension width, height; width = w->core.width; height = w->core.height; if (Layout(w, FALSE, FALSE, &width, &height)) XtAppWarning(XtWidgetToApplicationContext(w), "List Widget: Size changed when it shouldn't have when resising."); } /* Function Name: Layout * Description: lays out the item in the list. * Arguments: w - the widget. * xfree, yfree - TRUE if we p^׳ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.C;2T<WC%are free to resize the widget in * this direction. * width, height - the is the current width and height that * we are going to layout the list widget to, * depending on xfree and yfree of course. * * Returns: TRUE if width or height have been changed. */ static Boolean Layout(w, xfree, yfree, width, height) Widget w; Boolean xfree, yfree; Dimension *width, *height; { ListWidget lw = (ListWidget) w; Boolean change = FALSE; /* * If force columns is set then always use number of columns specified * by default_cols. */ if (lw->list.force_cols) { lw->list.ncols = lw->list.default_cols; if (lw->list.ncols <= 0) lw->list.ncols = 1; /* 12/3 = 4 and 10/3 = 4, but 9/3 = 3 */ lw->list.nrows = ( ( lw->list.nitems - 1) / lw->list.ncols) + 1 ; if (xfree) { /* If allowed resize width. */ *width = lw->list.ncols * lw->list.col_width + 2 * lw->list.internal_width; change = TRUE; } if (yfree) { /* If allowed resize height. */ *height = (lw->list.nrows * lw->list.row_height) + 2 * lw->list.internal_height; change = TRUE; } return(change); } /* * If both width and height are free to change the use default_cols * to determine the number columns and set new width and height to * just fit the window. */ if (xfree && yfree) { lw->list.ncols = lw->list.default_cols; if (lwqkn XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.H;3T<B(->list.ncols <= 0) lw->list.ncols = 1; lw->list.nrows = ( ( lw->list.nitems - 1) / lw->list.ncols) + 1 ; *width = lw->list.ncols * lw->list.col_width + 2 * lw->list.internal_width; *height = (lw->list.nrows * lw->list.row_height) + 2 * lw->list.internal_height; change = TRUE; } /* * If the width is fixed then use it to determine the number of columns. * If the height is free to move (width still fixed) then resize the height * of the widget to fit the current list exactly. */ else if (!xfree) { lw->list.ncols = ( (*width - 2 * lw->list.internal_width) / lw->list.col_width); if (lw->list.ncols <= 0) lw->list.ncols = 1; lw->list.nrows = ( ( lw->list.nitems - 1) / lw->list.ncols) + 1 ; if ( yfree ) { *height = (lw->list.nrows * lw->list.row_height) + 2 * lw->list.internal_height; change = TRUE; } } /* * The last case is xfree and !yfree we use the height to determine * the number of rows and then set the width to just fit the resulting * number of columns. */ else if (!yfree) { /* xfree must be TRUE. */ lw->list.nrows = (*height - 2 * lw->list.internal_height) / lw->list.row_height; if (lw->list.nrows <= 0) lw->list.nrows = 1; lw->list.ncols = (( lw->list.nitems - 1 ) / lw->list.nrows) + 1; *width = lw->list.ncols * lw->list.col_width + 2 * lw->list.internal_width; change = TRUE; } return(change); } /* Function Name: Notify * Description: Notifies thr6wX XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2K.H;3T<.+e user that a button has been pressed, and * calles the callback, if the XtNpasteBuffer resource * is true then the name of the item is also put in the * X cut buffer ( buf (0) ). * Arguments: w - the widget that the notify occured in. * event - event that caused this notification. * params, num_params - not used. * Returns: none. */ /* ARGSUSED */ static void Notify(w, event, params, num_params) Widget w; XEvent * event; String * params; Cardinal *num_params; { ListWidget lw = ( ListWidget ) w; int item, item_len; XawListReturnStruct ret_value; /* * Find item and if out of range then unhighlight and return. * * If the current item is unhighlighted then the user has aborted the * notify, so unhighlight and return. */ if ( ((CvtToItem(w, event->xbutton.x, event->xbutton.y, &item)) == OUT_OF_RANGE) || (lw->list.highlight != item) ) { XawListUnhighlight(w); return; } item_len = strlen(lw->list.list[item]); if ( lw->list.paste ) /* if XtNpasteBuffer set then paste it. */ XStoreBytes(XtDisplay(w), lw->list.list[item], item_len); /* * Call Callback function. */ ret_value.string = lw->list.list[item]; ret_value.list_index = item; XtCallCallbacks( w, XtNcallback, (caddr_t) &ret_value); } /* Function Name: Unset * Description: unhighlights the current element. * Arguments: w - the widget that the event occured in. * eves XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2KP.H;3T<\.nt - not used. * params, num_params - not used. * Returns: none. */ /* ARGSUSED */ static void Unset(w, event, params, num_params) Widget w; XEvent * event; String * params; Cardinal *num_params; { XawListUnhighlight(w); } /* Function Name: Set * Description: Highlights the current element. * Arguments: w - the widget that the event occured in. * event - event that caused this notification. * params, num_params - not used. * Returns: none. */ /* ARGSUSED */ static void Set(w, event, params, num_params) Widget w; XEvent * event; String * params; Cardinal *num_params; { int item; ListWidget lw = (ListWidget) w; if ( (CvtToItem(w, event->xbutton.x, event->xbutton.y, &item)) == OUT_OF_RANGE) XawListUnhighlight(w); /* Unhighlight current item. */ else if ( lw->list.is_highlighted != item ) /* If this item is not */ XawListHighlight(w, item); /* highlighted then do it. */ } /* * Set specified arguments into widget */ static Boolean SetValues(current, request, new) Widget current, request, new; { ListWidget cl = (ListWidget) current; ListWidget rl = (ListWidget) request; ListWidget nl = (ListWidget) new; Boolean redraw = FALSE; if ((cl->list.foreground != rl->list.foreground) || (cl->core.background_pixel != rl->core.background_pixel) || (cl->list.font != rl->list.font) ) { XtDestroyGC(cl->list.normgc); XtDestroyGC(cl->list.graygc); XtDestroyGC(cl->list.revgc); tM XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2KP.H;3T<P1 GetGCs(new); redraw = TRUE; } /* Reset row height. */ if ((cl->list.row_space != rl->list.row_space) || (cl->list.font != rl->list.font)) nl->list.row_height = nl->list.font->max_bounds.ascent + nl->list.font->max_bounds.descent + nl->list.row_space; if ((cl->core.width != rl->core.width) || (cl->core.height != rl->core.height) || (cl->list.internal_width != rl->list.internal_width) || (cl->list.internal_height != rl->list.internal_height) || (cl->list.column_space != rl->list.column_space) || (cl->list.row_space != rl->list.row_space) || (cl->list.default_cols != rl->list.default_cols) || ( (cl->list.force_cols != rl->list.force_cols) && (rl->list.force_cols != rl->list.ncols) ) || (cl->list.vertical_cols != rl->list.vertical_cols) || (cl->list.longest != rl->list.longest) || (cl->list.nitems != rl->list.nitems) || (cl->list.font != rl->list.font) || (cl->list.list != rl->list.list) ) { ResetList(new, TRUE, TRUE); redraw = TRUE; } if (cl->list.list != rl->list.list) nl->list.highlight = NO_HIGHLIGHT; if ((cl->core.sensitive != rl->core.sensitive) || (cl->core.ancestor_sensitive != rl->core.ancestor_sensitive)) { nl->list.highlight = NO_HIGHLIGHT; redraw = TRUE; } if (!XtIsRealized(current)) return(FALSE);uQY XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LIST.C;2KP.H;3T<P4 return(redraw); } /* Exported Functions */ /* Function Name: XawListChange. * Description: Changes the list being used and shown. * Arguments: w - the list widget. * list - the new list. * nitems - the number of items in the list. * longest - the length (in Pixels) of the longest element * in the list. * resize - if TRUE the the list widget will * try to resize itself. * Returns: none. * NOTE: If nitems of longest are <= 0 then they will be calculated. * If nitems is <= 0 then the list needs to be NULL terminated. */ void XawListChange(w, list, nitems, longest, resize_it) Widget w; char ** list; int nitems, longest; Boolean resize_it; { ListWidget lw = (ListWidget) w; lw->list.list = list; if (nitems <= 0) nitems = 0; lw->list.nitems = nitems; if (longest <= 0) longest = 0; lw->list.longest = longest; ResetList(w, resize_it, resize_it); lw->list.is_highlighted = lw->list.highlight = NO_HIGHLIGHT; if ( XtIsRealized(w) ) Redisplay(w, NULL, NULL); } /* Function Name: XawListUnhighlight * Description: unlights the current highlighted element. * Arguments: w - the widget. * Returns: none. */ void XawListUnhighlight(w) Widget w; { ListWidget lw = ( ListWidget ) w; lw->list.highlight = NO_HIGHLIGHT; if (lw->list.is_highlighted != NO_HIGHLIGHT) PaintItemName(w, lw->list.is_highlightev)~ms 3D5` qQ`c &@;W?EgXHI|c4-$W_m  XA>J3)B{2AL_9h5r5aPX[If8.:2&S#":tb~H`;XS{VtNyU`m?>=C5/{~D-G({32"W[] X'5b YZJ S~lP~6p#1]+!<_ $HbX- _A : F vC* 3wmS`!\r)7 m^?# urC' :!YNIH d9AE&%7{/;UFYD(a*)`4:4{0SCe_$R9OK b FKe)"H&vjG-bn6eubKP 9(I6 )A% ;A4L5 B3[^:|tDV#")x}Lfi!@PtOxz3jlFSP?',S`Z(y|)tHE[a);v^H]X~N| Dbx vZ!L jt{ Vs~|x#~vcReu@G 4NPKK2~{Sy6g|bz\`UM{YMC&U om k0!:~>=:C$N<@l6K+`.&aFA ~[8?W? E)KPc:MDe(y> T [j!5gw-HWq!t  c@]CKW^V\EgXT6dALW.Y}4QA71Da+H^kOo}KQ88>CAcTD]0lQ 0L X Z9&\Hu@89H@ RL+,$p5e]O o{C=}-93Mc W]+n_h,j! ygD)igRD enq92?5TB^)SVIY _ks6v.le31p&s]n 1(KK+?'!-1*I,q\#8{dP:u8H&&,GStHdDbNlist.highlight = item; if (lw->list.is_highlighted != NO_HIGHLIGHT) PaintItemName(w, lw->list.is_highlighted); /* Unhighlight. */ PaintItemName(w, item); /* HIGHLIGHT this one. */ } } /* Function Name: XawListShowCurrent * Description: returns the currently highlighted object. * Arguments: w - the list widget. * Returns: the info about the currently highlighted object. */ XawListReturnStruct * XawListShowCurrent(w) Widget w; { ListWidget lw = ( ListWidget ) w; XawListReturnStruct * ret_val; ret_val = (XawListReturnStruct *) XtMalloc (sizeof (XawListReturnStruct)); ret_val->list_index = lw->list.highlight; if (ret_val->list_index == XAW_LIST_NONE) ret_val->string = ""; else ret_val->string = lw->list.list[ ret_val->list_index ]; return(ret_val); } x XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LIST.H;2.C;12Of*[MAHAN.XTERM.LIB.XAW]LIST.H;2+,r./@ 4OzF-zr0123KPWO56zF7 F80_9G@HJ/* * $XConsortium: List.h,v 1.15 89/12/11 15:08:59 kit Exp $ * * 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 Ly@/ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LIST.H;2.C;12OOSS 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. */ /* This is the List widget, it is useful to display a list, without the * overhead of having a widget for each item in the list. It allows * the user to select an item in a list and notifies the application through * a callback function. * * Created: 8/13/88 * By: Chris D. Peterson * MIT X Consortium */ #ifndef _XawList_h #define _XawList_h /*********************************************************************** * * List Widget * ***********************************************************************/ #ifdef vax11c #include "SIMPLE.H" #else #include #endif /* vax11c */ /* Resources: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 callback Callback XtCallbackList NULL **6 columnSpacing Spacing Dimension 6 cursor Cursor Cursor left_ptr defaultColumns Columns int 2 **5 destroyCallback Callback Pointer NULL font Font XFontStruct* XtDefaultFont forceColumns Columns Boolean False **5 foreground Foreground Pixel XtDefaultForegroundz  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LIST.H;2.C;12OF height Height Dimension 0 **1 insensitiveBorder Insensitive Pixmap Gray internalHeight Height Dimension 2 internalWidth Width Dimension 4 list List String * NULL **2 longest Longest int 0 **3 **4 mappedWhenManaged MappedWhenManaged Boolean True numberStrings NumberStrings int 0 **4 pasteBuffer Boolean Boolean False rowSpacing Spacing Dimension 4 sensitive Sensitive Boolean True verticalList Boolean Boolean False width Width Dimension 0 **1 x Position Position 0 y Position Position 0 **1 - If the Width or Height of the list widget is zero (0) then the value is set to the minimum size necessay to fit the entire list. If both Width and Height are zero then they are adjusted to fit the entire list that is created width the number of default columns specified in the defaultColumns resource. **2 - This is an array of strings the specify elements of the list. This resource must be specified. (What good is a list widget without a list?? :-) **3 - Longest is the length of the widest string in pixels. **4 - If either of these values are zero (0) then the list widget calculates the correct value. (This allows you to make startup faster if you already have this info{8; XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LIST.H;2.C;12Oی rmation calculated) NOTE: If the numberStrings value is zero the list must be NULL terminated. **5 - By setting the List.Columns resource you can force the application to have a given number of columns. **6 - This returns the name and index of the item selected in an XawListReturnStruct that is pointed to by the client_data in the CallbackProc. */ /* * Value returned when there are no highlighted objects. */ #define XAW_LIST_NONE -1 #define XtCList "List" #define XtCSpacing "Spacing" #define XtCColumns "Columns" #define XtCLongest "Longest" #define XtCNumberStrings "NumberStrings" #define XtNcursor "cursor" #define XtNcolumnSpacing "columnSpacing" #define XtNdefaultColumns "defaultColumns" #define XtNforceColumns "forceColumns" #define XtNlist "list" #define XtNlongest "longest" #define XtNnumberStrings "numberStrings" #define XtNpasteBuffer "pasteBuffer" #define XtNrowSpacing "rowSpacing" #define XtNverticalList "verticalList" /* Class record constants */ #ifndef XAW_LIST_WIDGET #ifdef vax11c globalref WidgetClass listWidgetClass; #else extern WidgetClass listWidgetClass; #endif /* vax11c */ #endif /* !XAW_LIST_WIDGET */ typedef struct _ListClassRec *ListWidgetClass; typedef struct _ListRec *ListWidget; /* The list return structure. */ typedef struct _XawListReturnStruct { String string; int list_index; } XawListReturnStruct; #ifdef XAW_BC /************************************************************* * For Compatibility |½ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LIST.H;2.C;12O  only. */ #define XtListReturnStruct XawListReturnStruct #define XT_LIST_NONE XAW_LIST_NONE #define XtListChange XawListChange #define XtListUnhighlight XawListUnhighlight #define XtListHighlight XawListHighlight #define XtListShowCurrent XawListShowCurrent /*************************************************************/ #endif /* XAW_BC */ /****************************************************************** * * Exported Functions * *****************************************************************/ /* Function Name: XawListChange. * Description: Changes the list being used and shown. * Arguments: w - the list widget. * list - the new list. * nitems - the number of items in the list. * longest - the length (in Pixels) of the longest element * in the list. * resize - if TRUE the the list widget will * try to resize itself. * Returns: none. * NOTE: If nitems of longest are <= 0 then they will be caluculated. * If nitems is <= 0 then the list needs to be NULL terminated. */ extern void XawListChange(); /* w, list, nitems, longest, resize */ /* Function Name: XawListUnhighlight * Description: unlights the current highlighted element. * Arguments: w - the widget. * Returns: none. */ extern void XawListUnhighlight(); /* w */ /* Function Name: XawListHighlight * Description: Highlights the }' XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LIST.H;2.C;12Ogiven item. * Arguments: w - the list widget. * item - the item to hightlight. * Returns: none. */ extern void XawListHighlight(); /* w, item */ /* Function Name: XawListShowCurrent * Description: returns the currently highlighted object. * Arguments: w - the list widget. * Returns: the info about the currently highlighted object. */ extern XawListReturnStruct * XawListShowCurrent(); /* w */ #endif /* _XawList_h */ /* DON'T ADD STUFF AFTER THIS #endif */ *[MAHAN.XTERM.LIB.XAW]LISTP.H;2+,r . /@ 4O AF-zr0123KPWO 56F7cF8 `9G@HJ/* * $XConsortium: ListP.h,v 1.12 89/12/11 15:09:04 kit Exp $ * * 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 per~~ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LISTP.H;2C;12O Œtaining 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 D. Peterson, MIT X Consortium */ /* * ListP.h - Private definitions for List widget * * This is the List widget, it is useful to display a list, without the * overhead of having a widget for each item in the list. It allows * the user to select an item in a list and notifies the application through * a callback function. * * Created: 8/13/88 * By: Chris D. Peterson * MIT - Project Athena */ #ifndef _XawListP_h #define _XawListP_h /*********************************************************************** * * List Widget Private Data * ***********************************************************************/ #ifdef vax11c #include "SIMPLEP.H" #include "LIST.H" #else #include #include #endif /* vax11c */ #define NO_HIGHLIGHT  XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LISTP.H;2C;12O _ XAW_LIST_NONE #define OUT_OF_RANGE -1 #define OKAY 0 /* New fields for the List widget class record */ typedef struct {int foo;} ListClassPart; /* Full class record declaration */ typedef struct _ListClassRec { CoreClassPart core_class; SimpleClassPart simple_class; ListClassPart list_class; } ListClassRec; #ifndef XAW_LIST_WIDGET #ifdef vax11c globalref ListClassRec listClassRec; #else extern ListClassRec listClassRec; #endif /* vax11c */ #endif /* !XAW_LIST_WIDGET */ /* New fields for the List widget record */ typedef struct { /* resources */ Pixel foreground; Dimension internal_width, internal_height, column_space, row_space; int default_cols; Boolean force_cols, paste, vertical_cols; int longest; int nitems; /* number of items in the list. */ XFontStruct *font; String * list; XtCallbackList callback; /* private state */ int is_highlighted, /* set to the item currently highlighted. */ highlight, /*set to the item that should be highlighted.*/ col_width, /* width of each column. */ row_height, /* height of each row. */ nrows, /* number of rows in the list. */ ncols; /* number of columns in the list. */ GC normgc, /* a couple o' GC's. */ revgc, graygc; /* used when inactiv XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LISTP.H;2C;12O `e. */ } ListPart; /**************************************************************** * * Full instance record declaration * ****************************************************************/ typedef struct _ListRec { CorePart core; SimplePart simple; ListPart list; } ListRec; #endif /* _XawListP_h */ *[MAHAN.XTERM.LIB.XAW]LOGO.C;2+,r./@ 4Q <$F-zr0123KPWO 56$F7F8pG`9G@HJ#ifndef lint static char Xrcsid[] = "$XConsortium: Logo.c,v 1.11 89/10/09 16:20:39 jim Exp $"; #endif /* Copyright 1988 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 advert6~ms 67k^il Y';N \]m:vg!  7U"vqYbTl] }*wDVI>:n/ 'Ac3N1aF=x`!iA'?>[F%AhZrxe&'>AgE6?S-|x%2q :jMAvMRsuL0j*c*R4_S<{nMP@#S:q>@N/,~W@yNa9/'\~qnn`"m-=1VVE>co.zM!7eU^e:*dbtQdmL))Tn^X8jxgQ?JaB*yAyzP sevƍZ"jiRV4,e#;j<&<|<91DZhAg_>I]hk:g Fh;{ _&pHE | L 2"ЛY&bi4Ee|p3 b H8 `E5oEd0 E1[1_/M Sh|`FBi utx<{ VM-r[zY]3 8Zk|:3z+pb=ks3](_Z>FW7!s% 3`cUft:LU B <pgN'bhJ|4v|? vx<{U_E^h gl=?> OF$)(GyH,sM E,WM/yBy :%bbB0Qo@wrF8KINoHCYI_dD9bN]~/@kldP^3K C7vm  Q4f Gq(!/cQS+ k9d0Q2JK yU@1?4c"|/m}i*]wQ|Km@0bD(ot0T8(p(gugI%::_s ^s Ll 5z5>"AM .jy26Gg -8 N"}X 6Gs]<_EsNL{T?TB/!(-~X"]~x|*&2 bHI0|y+>B{SS#UsM&S,BpH[Nd;Lf&huc (|_ ~E]uXG% 'N(ODcX m@Q71Pl;4iVGft!D@"viL.w:'7,S]]I+ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LOGO.C;2.C;12Qmising 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. */ #define XAW_LOGO_WIDGET #ifdef vax11c #include #include #include "XawInit.h" #include "LogoP.h" #else #include #include #include #include #endif /* vax11c */ static Dimension defDim = 100; static XtResource resources[] = { {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension), XtOffset(Widget,core.width), XtRDimension, (caddr_t)&defDim}, {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension), XtOffset(Widget,core.height), XtRDimension, (caddr_t)&defDim}, {XtNbackground, XtCBackground, XtRPixel, sizeof(Pixel), XtOffset(Widget,core.background_pixel), XtRString, "White"}, {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), XtOffset(LogoWidget,logo.fgpixel), XtRString, "Black"}, {XtNreverseVideo, XtCReverseVideo, XtRBoolean, sizeof (Boolean), XtOffset(LogoWidget,logo.reverse_video), XtRString, "FALSE"}, }; static void Initialize(), Realize(), Destroy(), Redisplay(); static Boolean SetValues(); #ifdef vax11c globaldef {"logoclassrec"} noshare #endif /* vax11c */ LogoClassRec logoClassRec = { { /* core fields */ /* superclass */ &widgetClassRec, /* class_name */ "Logo", /* wid XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LOGO.C;2.C;12Qget_size */ sizeof(LogoRec), /* class_initialize */ XawInitializeWidgetSet, /* 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 */ NULL, /* 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 {"logowidgetclass"} noshare #endif /* vax11c */ WidgetClass logoWidgetClass = (WidgetClass) &logoClassRec; /* ARGSUSED */ static void Initialize (request, new) Widget request, new; { LogoWidget w = (LogoWidget)new; XGCValues gcv; if (w->logo.reverse_video) { Pixel fg = w->logo.fgpixel; Pixel bg = w->core.background_pixel; if (w->core.border_pixel == fg) w->core.border_pixel = bg; w->logo.fgpixel = bg; w->core.background_pixel = fg;-C XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LOGO.C;2.C;12Q& } gcv.foreground = w->logo.fgpixel; w->logo.foreGC = XtGetGC((Widget)w, GCForeground, &gcv); gcv.foreground = w->core.background_pixel; w->logo.backGC = XtGetGC((Widget)w, GCForeground, &gcv); } static void Realize (gw, valueMask, attrs) Widget gw; XtValueMask *valueMask; XSetWindowAttributes *attrs; { XtCreateWindow( gw, InputOutput, (Visual *)CopyFromParent, *valueMask, attrs); } static void Destroy (gw) Widget gw; { LogoWidget w = (LogoWidget) gw; XtDestroyGC (w->logo.foreGC); XtDestroyGC (w->logo.backGC); } /* ARGSUSED */ static void Redisplay (gw, event, region) Widget gw; XEvent *event; /* unused */ Region region; /* unused */ { LogoWidget w = (LogoWidget) gw; XmuDrawLogo(XtDisplay(w), XtWindow(w), w->logo.foreGC, w->logo.backGC, 0, 0, (unsigned int) w->core.width, (unsigned int) w->core.height); } /* ARGSUSED */ static Boolean SetValues (gcurrent, grequest, gnew) Widget gcurrent, grequest, gnew; { LogoWidget current = (LogoWidget) gcurrent; LogoWidget new = (LogoWidget) gnew; Boolean redisplay = FALSE; XGCValues gcv; if ((new->logo.fgpixel != current->logo.fgpixel) || (new->core.background_pixel != current->core.background_pixel)) { XtDestroyGC (current->logo.foreGC); XtDestroyGC (current->logo.backGC); gcv.foreground = new->logo.fgpixel; new->logo.foreGC = XtGetGC(gnew, GCForeground, &gcv); gcv.foreground = new->core.background_pixel; new->logo.backGC = XtGetGC(gnew, GCForeground, &/ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LOGO.C;2.C;12Q gcv); redisplay = TRUE; } return (redisplay); } *[MAHAN.XTERM.LIB.XAW]LOGO.H;2+,r./@ 4;K5HF-zr0123KPWO565HF7p_F8Mz`9G@HJ/* * $XConsortium: Logo.h,v 1.9 89/05/11 01:05:50 kit Exp $ */ /* Copyright 1988 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 distri" XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]LOGO.H;2.C;12;bution 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 _XawLogo_h #define _XawLogo_h /* Parameters: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel White border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 destroyCallback Callback Pointer NULL foreground Foreground Pixel Black height Height Dimension 100 mappedWhenManaged MappedWhenManaged Boolean True reverseVideo ReverseVideo Boolean False width Width Dimension 100 x Position Position 0 y Position Position 0 */ typedef struct _LogoRec *LogoWidget; typedef struct _LogoClassRec *LogoWidgetClass; #ifndef XAW_LOGO_WIDGET #ifdef vax11c globalref WidgetClass logoWidgetClass; #else extern WidgetClass logoWidgetClass; #endif /* vax11c */ #endif /* !XAW_LOGO_WIDGET */ #endif /* _XawLogo_h */ _fR XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LOGOP.H;2C;12;2*[MAHAN.XTERM.LIB.XAW]LOGOP.H;2+,r ./@ 4;jF-zr0123KPWO56F7F8`9G@HJ/* * $XConsortium: LogoP.h,v 1.6 89/05/11 01:05:52 kit Exp $ */ /* Copyright 1988 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 _XawLogoP_h #define _XawLogoP_h #ifdef vax11c #include "Logo.h" #else #include #endif /* vax11c */ typedef struct { Pixel fgpixel; Boolean reverse_video; GC foreGC; GC backGC; } LogoPart; typedef struct _LogoRec { CorePart core; LogoPart logo;0 ^ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]LOGOP.H;2C;12; } LogoRec; typedef struct {int dummy;} LogoClassPart; typedef struct _LogoClassRec { CoreClassPart core_class; LogoClassPart logo_class; } LogoClassRec; #ifndef XAW_LOGO_WIDGET #ifdef vax11c globalref LogoClassRec logoClassRec; #else extern LogoClassRec logoClassRec; #endif /* vax11c */ #endif /* !XAW_LOGO_WIDGET */ #endif /* _XawLogoP_h */  *[MAHAN.XTERM.LIB.XAW]MAILBOX.C;8+,r .(/@ 4U($P`F-zr0123KPWO%56P`F70SF80 9a9G@HJ/* * $XConsortium: Mailbox.c,v 1.35 89/10/09 16:51:44 jim Exp $ * * Copyright 1988 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 perK XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]MAILBOX.C;812U(taining 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. * * Author: Jim Fulton, MIT X Consortium * * I recommend that you use the new mailfull and mailempty bitmaps instead of * the ugly mailboxes: * * XBiff*fullPixmap: mailfull * XBiff*emptyPixmap: mailempty */ #define XAW_MAILBOX_WIDGET #include /* for printing error messages */ #ifndef vax11c #include /* for getting username */ #endif /* !vax11c */ #ifdef vax11c #include /* for cursor constants */ #include /* for useful atom names */ #include /* for toolkit stuff */ #include /* for stat() ** needs types.h ***/ #include /* for flag up (mail present) bits */ #include /* for flag down (mail not here) */ #include "XawInit.h" #include "MailboxP.h" /* for implementation mailbox stuff */ #include /* for XmuCvtStringToBitmap */ #ifdef SHAPE #include #endif #else #include /* for cursor constants */ #include /* for useful atom names */ #include /* for toolkit stuff */ #include /* for stat() ** needs types.h ***/ #include /* for flag up (mail present) bits tl XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]MAILBOX.C;812U(q2*/ #include /* for flag down (mail not here) */ #include #include /* for implementation mailbox stuff */ #include /* for XmuCvtStringToBitmap */ #ifdef SHAPE #include #endif #endif /* vax11c */ /* * The default user interface is to have the mailbox turn itself off whenever * the user presses a button in it. Expert users might want to make this * happen on EnterWindow. It might be nice to provide support for some sort of * exit callback so that you can do things like press q to quit. */ static char defaultTranslations[] = ": unset()"; static void Check(), Set(), Unset(); static XtActionsRec actionsList[] = { { "check", Check }, { "unset", Unset }, { "set", Set }, }; /* Initialization of defaults */ #define offset(field) XtOffset(MailboxWidget,mailbox.field) #define goffset(field) XtOffset(Widget,core.field) static Dimension defDim = 48; static Pixmap nopix = None; static XtResource resources[] = { { XtNwidth, XtCWidth, XtRDimension, sizeof (Dimension), goffset (width), XtRDimension, (caddr_t)&defDim }, { XtNheight, XtCHeight, XtRDimension, sizeof (Dimension), goffset (height), XtRDimension, (caddr_t)&defDim }, { XtNupdate, XtCInterval, XtRInt, sizeof (int), offset (update), XtRString, "30" }, { XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel), offset (foreground_pixel), XtRString, "black" }, { XtNbackground, XtCBackgrou]U7 XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]MAILBOX.C;812U(nd, XtRPixel, sizeof (Pixel), goffset (background_pixel), XtRString, "white" }, { XtNreverseVideo, XtCReverseVideo, XtRBoolean, sizeof (Boolean), offset (reverseVideo), XtRString, "FALSE" }, { XtNfile, XtCFile, XtRString, sizeof (String), offset (filename), XtRString, NULL }, { XtNcheckCommand, XtCCheckCommand, XtRString, sizeof(char*), offset (check_command), XtRString, NULL}, { XtNvolume, XtCVolume, XtRInt, sizeof(int), offset (volume), XtRString, "33"}, { XtNonceOnly, XtCBoolean, XtRBoolean, sizeof(Boolean), offset (once_only), XtRImmediate, (caddr_t)False }, { XtNfullPixmap, XtCPixmap, XtRBitmap, sizeof(Pixmap), offset (full.bitmap), XtRString, "flagup" }, { XtNfullPixmapMask, XtCPixmapMask, XtRBitmap, sizeof(Pixmap), offset (full.mask), XtRBitmap, (caddr_t) &nopix }, { XtNemptyPixmap, XtCPixmap, XtRBitmap, sizeof(Pixmap), offset (empty.bitmap), XtRString, "flagdown" }, { XtNemptyPixmapMask, XtCPixmapMask, XtRBitmap, sizeof(Pixmap), offset (empty.mask), XtRBitmap, (caddr_t) &nopix }, { XtNflip, XtCFlip, XtRBoolean, sizeof(Boolean), offset (flipit), XtRString, "true" }, #ifdef SHAPE { XtNshapeWindow, XtCShapeWindow, XtRBoolean, sizeof(Boolean), offset (shapeit), XtRString, "false" }, #endif }; #undef offset #undef goffset static void GetMailFile(), CloseDown(); static void check_mailbox(), redraw_mailbox(), beep(); static void ClassInitialize(), Initialize(), Realize(), Destroy(), Redisplay(); static Boolean SetValues(); #ifdef vax11c globalde[K=lcmxn- :+Now>DIQu#wN+aNGg^u(kL6Z%c~nwYe XWi<_l 8Zdf*mnImY]|W5{">ow,dIa!8w!m$EwNeRO%:=M3{"&tWT.3UoixAW c1_]x=T_x=,P=J)ZR?)([F,xzm`fUv4)O:5&+V -u 4fL5 W8fiV&~0ey )zO961D0$OCO)P(Ot2s}.M:+6yXr}H4D);%:k(nl9"~ v3"![9ZFv}8.0u"6%sl:g"v~u2>E{1R3E_YF c%^(SL/D*Qj)]MwWK{7*]-T.+E Z;rZ>/nxo[J_]o H, AT9r44/b$ 4>y rLqRpW!5b'F?u.0 Bty97Ate7>+X)^,\> Iq)h}-P>+<lOJl<XZ 8aIR}t-\h#,~^LAkG#4O (wBxI~<-YrN%q{^@A~g#A*   ]zuNe]/%YMT|IIiGE{t(t$+4E.|eBu.)SQYF\GIgch  3]~cz2Go]MJ1 FO3E U Vg+wx U~ ,WrGCYNE^uKLj@r j?L  75C r*Y3pPtJF yNCNGfqWqJF:>g#IHWgX-S f {"mailboxclassrec"} noshare #endif /* vax11c */ MailboxClassRec mailboxClassRec = { { /* core fields */ /* superclass */ &widgetClassRec, /* class_name */ "Mailbox", /* widget_size */ sizeof(MailboxRec), /* class_initialize */ ClassInitialize, /* class_part_initialize */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ Realize, /* actions */ actionsList, /* num_actions */ XtNumber(actionsList), /* resources */ resources, /* resource_count */ XtNumber(resources), /* xrm_class */ NULL, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave */ TRUE, /* visible_interest */ FALSE, /* destroy */ Destroy, /* resize */ NULL, /* 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 */ defaultTranslations, /* query_geometry */ XtInheritQueryGeometry, /* display_accelerator */ XtInheritDisplayAccelerator, /* extension */ NULL } }; #ifdef vax11c globaldef {"mailboxwidgetclass"} noshare #endif /* vax11c */ WidgetClass mailboxWidgetClass = (WidgetClass) &mailboxClassRec; /* * widget initialization */ static void ClassInitialize () { static XtConvertArgRec screenConvertArg[] = { } XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]MAILBOX.C;812U( { XtWidgetBaseOffset, (caddr_t) XtOffset(Widget, core.screen), sizeof(Screen *) } }; XawInitializeWidgetSet(); XtAddConverter (XtRString, XtRBitmap, XmuCvtStringToBitmap, screenConvertArg, XtNumber(screenConvertArg)); return; } static GC get_mailbox_gc (w) MailboxWidget w; { XtGCMask valuemask; XGCValues xgcv; valuemask = GCForeground | GCBackground | GCFunction | GCGraphicsExposures; xgcv.foreground = w->mailbox.foreground_pixel; xgcv.background = w->core.background_pixel; xgcv.function = GXcopy; xgcv.graphics_exposures = False; /* this is Bool, not Boolean */ return (XtGetGC ((Widget) w, valuemask, &xgcv)); } /* ARGSUSED */ static void Initialize (request, new) Widget request, new; { MailboxWidget w = (MailboxWidget) new; #ifdef SHAPE int shape_event_base, shape_error_base; #endif if (!w->mailbox.filename) GetMailFile (w); if (w->core.width <= 0) w->core.width = 1; if (w->core.height <= 0) w->core.height = 1; if (w->mailbox.reverseVideo) { Pixel tmp; tmp = w->mailbox.foreground_pixel; w->mailbox.foreground_pixel = w->core.background_pixel; w->core.background_pixel = tmp; } #ifdef SHAPE if (w->mailbox.shapeit && !XShapeQueryExtension (XtDisplay (w), &shape_event_base, &shape_error_base)) w->mailbox.shapeit = False; w->mailbox.shape_cache.mask = None; #endif w->mailbox.gc = get_mailbox_gc (w); w->mailbox.interval_id = (XtIntervalId) 0; w->mailbox.full.pixmap~ XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]MAILBOX.C;812U(M = None; w->mailbox.empty.pixmap = None; return; } /* * action procedures */ /* * pretend there is new mail; put widget in flagup state */ /* ARGSUSED */ static void Set (gw, event, params, nparams) Widget gw; XEvent *event; String *params; Cardinal *nparams; { MailboxWidget w = (MailboxWidget) gw; w->mailbox.last_size = -1; check_mailbox (w, TRUE, FALSE); /* redraw, no reset */ return; } /* * ack the existing mail; put widget in flagdown state */ /* ARGSUSED */ static void Unset (gw, event, params, nparams) Widget gw; XEvent *event; String *params; Cardinal *nparams; { MailboxWidget w = (MailboxWidget) gw; check_mailbox (w, TRUE, TRUE); /* redraw, reset */ return; } /* * look to see if there is new mail; if so, Set, else Unset */ /* ARGSUSED */ static void Check (gw, event, params, nparams) Widget gw; XEvent *event; String *params; Cardinal *nparams; { MailboxWidget w = (MailboxWidget) gw; check_mailbox (w, TRUE, FALSE); /* redraw, no reset */ return; } /* ARGSUSED */ static void clock_tic (client_data, id) caddr_t client_data; XtIntervalId *id; { MailboxWidget w = (MailboxWidget) client_data; check_mailbox (w, FALSE, FALSE); /* no redraw, no reset */ /* * and reset the timer */ w->mailbox.interval_id = XtAddTimeOut (w->mailbox.update * 1000, clock_tic, (caddr_t) w); return; } static Pixmap make_pixmap (dpy, w, bitmap, depth, flip, widthpT  XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]MAILBOX.C;812U(b, heightp) Display *dpy; MailboxWidget w; Pixmap bitmap; Boolean flip; int depth; int *widthp, *heightp; { Window root; int x, y; unsigned int width, height, bw, dep; unsigned long fore, back; if (!XGetGeometry (dpy, bitmap, &root, &x, &y, &width, &height, &bw, &dep)) return None; *widthp = (int) width; *heightp = (int) height; if (flip) { fore = w->core.background_pixel; back = w->mailbox.foreground_pixel; } else { fore = w->mailbox.foreground_pixel; back = w->core.background_pixel; } return XmuCreatePixmapFromBitmap (dpy, w->core.window, bitmap, width, height, depth, fore, back); } static void Realize (gw, valuemaskp, attr) Widget gw; XtValueMask *valuemaskp; XSetWindowAttributes *attr; { MailboxWidget w = (MailboxWidget) gw; register Display *dpy = XtDisplay (w); int depth = w->core.depth; *valuemaskp |= (CWBitGravity | CWCursor); attr->bit_gravity = ForgetGravity; attr->cursor = XCreateFontCursor (dpy, XC_top_left_arrow); XtCreateWindow (gw, InputOutput, (Visual *) CopyFromParent, *valuemaskp, attr); /* * build up the pixmaps that we'll put into the image */ if (w->mailbox.full.bitmap == None) { w->mailbox.full.bitmap = XCreateBitmapFromData (dpy, w->core.window, mailfull_bits, mailfull_width, mailfull_height); } if (w->mailbox.empty.bitmap == None) { w->mailbox.empty.bitmap = XCreateBitmapFromData (dpy, w->core.window, mailempty̐7 XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]MAILBOX.C;82U(O_bits, mailempty_width, mailempty_height); } w->mailbox.empty.pixmap = make_pixmap (dpy, w, w->mailbox.empty.bitmap, depth, False, &w->mailbox.empty.width, &w->mailbox.empty.height); w->mailbox.full.pixmap = make_pixmap (dpy, w, w->mailbox.full.bitmap, depth, w->mailbox.flipit, &w->mailbox.full.width, &w->mailbox.full.height); #ifdef SHAPE if (w->mailbox.empty.mask == None && w->mailbox.full.mask == None) w->mailbox.shapeit = False; #endif w->mailbox.interval_id = XtAddTimeOut (w->mailbox.update * 1000, clock_tic, (caddr_t) w); #ifdef SHAPE w->mailbox.shape_cache.mask = None; #endif return; } static void Destroy (gw) Widget gw; { MailboxWidget w = (MailboxWidget) gw; Display *dpy = XtDisplay (gw); XtFree (w->mailbox.filename); if (w->mailbox.interval_id) XtRemoveTimeOut (w->mailbox.interval_id); XtDestroyGC (w->mailbox.gc); #define freepix(p) if (p) XFreePixmap (dpy, p) freepix (w->mailbox.full.bitmap); /* until cvter does ref cnt */ freepix (w->mailbox.full.mask); /* until cvter does ref cnt */ freepix (w->mailbox.full.pixmap); freepix (w->mailbox.empty.bitmap); /* until cvter does ref cnt */ freepix (w->mailbox.empty.mask); /* until cvter does ref cnt */ freepix (w->mailbox.empty.pixmap); #ifdef SHAPE freepix (w->mailbox.shape_cache.mask); #endif #undef freepix return; } static void Redisplay (gw) Widget gw; { MailboxWidget w = (MailboxWi= XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]MAILBOX.C;82U(dget) gw; check_mailbox (w, TRUE, FALSE); } static void check_mailbox (w, force_redraw, reset) MailboxWidget w; Boolean force_redraw, reset; { long mailboxsize = 0; if (w->mailbox.check_command != NULL) { switch (system(w->mailbox.check_command)) { case 0: mailboxsize = w->mailbox.last_size + 1; break; /* case 1 is no change */ case 2: mailboxsize = 0; /* treat everything else as no change */ } } else { struct stat st; if (stat (w->mailbox.filename, &st) == 0) { mailboxsize = st.st_size; } } /* * Now check for changes. If reset is set then we want to pretent that * there is no mail. If the mailbox is empty then we want to turn off * the flag. Otherwise if the mailbox has changed size then we want to * put the flag up. * * The cases are: * o forced reset by user DOWN * o no mailbox or empty (zero-sized) mailbox DOWN * o same size as last time no change * o bigger than last time UP * o smaller than last time but non-zero UP * * The last two cases can be expressed as different from last * time and non-zero. */ if (reset) { /* forced reset */ w->mailbox.flag_up = FALSE; force_redraw = TRUE; } else if (mailboxsize == 0) { /* no mailbox or empty */ w->mailbox.flag_up = FALSE; if (w->mailbox.last_size > 0) force_redraw = TRUE; /* if change */ } elsel XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]MAILBOX.C;82U(< if (mailboxsize != w->mailbox.last_size) { /* different size */ if (!w->mailbox.once_only || !w->mailbox.flag_up) beep(w); w->mailbox.flag_up = TRUE; force_redraw = TRUE; } w->mailbox.last_size = mailboxsize; if (force_redraw) redraw_mailbox (w); return; } /* * get user name for building mailbox */ static void GetMailFile (w) MailboxWidget w; { char *getlogin(); char *username; #ifdef vax11c username = getenv("USER"); #else username = getlogin (); if (!username) { struct passwd *pw = getpwuid (getuid ()); if (!pw) { fprintf (stderr, "%s: unable to find a username for you.\n", "Mailbox widget"); CloseDown (w, 1); } username = pw->pw_name; } #endif /* vax11c */ w->mailbox.filename = (String) XtMalloc (strlen (MAILBOX_DIRECTORY) + 1 + strlen (username) + 1); strcpy (w->mailbox.filename, MAILBOX_DIRECTORY); #ifdef vax11c strcat (w->mailbox.filename, "MAIL.MAI"); #else strcat (w->mailbox.filename, "/"); strcat (w->mailbox.filename, username); #endif /* vax11c */ return; } static void CloseDown (w, status) MailboxWidget w; int status; { Display *dpy = XtDisplay (w); XtDestroyWidget (w); XCloseDisplay (dpy); exit (status); } /* ARGSUSED */ static Boolean SetValues (gcurrent, grequest, gnew) Widget gcurrent, grequest, gnew; { MailboxWidget current = (MailboxWidget) gcurrent; MailboxWidget new = (MailboxWidget) gnew; Boolean redisplay = FALSE; if (curr+ XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]MAILBOX.C;82U(U0 ent->mailbox.update != new->mailbox.update) { if (current->mailbox.interval_id) XtRemoveTimeOut (current->mailbox.interval_id); new->mailbox.interval_id = XtAddTimeOut (new->mailbox.update * 1000, clock_tic, (caddr_t) gnew); } if (current->mailbox.foreground_pixel != new->mailbox.foreground_pixel || current->core.background_pixel != new->core.background_pixel) { XtDestroyGC (current->mailbox.gc); new->mailbox.gc = get_mailbox_gc (new); redisplay = TRUE; } return (redisplay); } /* * drawing code */ static void redraw_mailbox (w) MailboxWidget w; { register Display *dpy = XtDisplay (w); register Window win = XtWindow (w); register int x, y; GC gc = w->mailbox.gc; Pixel back = w->core.background_pixel; struct _mbimage *im; /* center the picture in the window */ if (w->mailbox.flag_up) { /* paint the "up" position */ im = &w->mailbox.full; if (w->mailbox.flipit) back = w->mailbox.foreground_pixel; } else { /* paint the "down" position */ im = &w->mailbox.empty; } x = (((int)w->core.width) - im->width) / 2; y = (((int)w->core.height) - im->height) / 2; XSetWindowBackground (dpy, win, back); XClearWindow (dpy, win); XCopyArea (dpy, im->pixmap, win, gc, 0, 0, im->width, im->height, x, y); #ifdef SHAPE /* * XXX - temporary hack; walk up widget tree to find top most parent (which * will be a shell) and mash it to have our shape. This will be replaced * by a special shell widget. _ XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]MAILBOX.C;8;2U(7# */ if (w->mailbox.shapeit) { Widget parent; for (parent = (Widget) w; XtParent(parent); parent = XtParent(parent)) { x += parent->core.x + parent->core.border_width; y += parent->core.y + parent->core.border_width; } if (im->mask != w->mailbox.shape_cache.mask || x != w->mailbox.shape_cache.x || y != w->mailbox.shape_cache.y) { XShapeCombineMask (XtDisplay(parent), XtWindow(parent), ShapeBounding, x, y, im->mask, ShapeSet); w->mailbox.shape_cache.mask = im->mask; w->mailbox.shape_cache.x = x; w->mailbox.shape_cache.y = y; } } #endif return; } static void beep (w) MailboxWidget w; { XBell (XtDisplay (w), w->mailbox.volume); return; }  *[MAHAN.XTERM.LIB.XAW]MAILBOX.H;2+,r ./@ 4O-F-zr0123KPWO56-F7pGF8za9G@HJGhs XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]MAILBOX.H;2;2Or/* * $XConsortium: Mailbox.h,v 1.19 89/07/21 01:55:46 kit Exp $ * * Copyright 1988 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. * * Author: Jim Fulton, MIT X Consortium */ #ifndef _XawMailbox_h #define _XawMailbox_h /* * Mailbox widget; looks a lot like the clock widget, don't it... */ /* resource names used by mailbox widget that aren't defined in StringDefs.h */ #define XtNupdate "update" /* command to exec */ #define XtNcheckCommand "checkCommand" #define XtNonceOnly "onceOnly" /* Int: volume for bell */ #define XtNvolume "volume" #define XtNfullPixmap "fullPixmap" #define XtNfullPixmapMask "fullPixmapMask" #define XtNemptyPixmap "emptyPixmap" #define XtNemptyPixmapMask "emptyPixmapMask" #define XtNflip "flip" #define XtNshapeWindow "shapeWindow" #define XtCCheckCommand "CheckCommand" #define XtCVolume "Volume" #define XtCPixmapMask "PixmapMask" #define XtCFlip "Flip" #define XtCSgPEv* f]&& &9&z-zi1 ISV"=IFX_~B$:i^w`dFEI$BO1l32B2 KY31] t;w93q1TxiZE,ZbYKdb5bfGHN &SlEVCf34cQEqDW r,'VuVem *~u]^UDbyF[6* >t7]+9f]d)~83acr ~cB\La'2ZK'61J SIg@2J$_'Ra+S~;sdw E8| p4^J6Y q3 +$VQ(U T, (CLr 7QS33Y` OpFsUj/Cz(*~CE'}{M BZ=M FT: H)[Na),AMaPO *'@"/bNIEL.3P2oxd)Y^`hW2Uy4se.IsZq~Ra ]>b~6U-F)x_dCZeV]%eb/h 4N_CRO5 -aq@)oeyv[2Nu!qE4 \&X]ND=NEj33PRON~qTh4lWg  ?<9oh/mKl WPm-urHEqx (  ^08cwIRRX48`FAg,0I;ado>:djvt+ )C{}cU7:nVCEMdG TIE CmX|>EHO3U'T5j)9$GI_(r)=d>}uX*(^ G~  mS%9x\|](#(G @ 4m Y,PX;G`>J=\>v&.( .u _me~V@8kW=9@ M8seg'|!*oKM z-2jDr "I -fQ^eH#y18V91Wtj98(B>D(j&v5PDrx*=o>IgX,C8%J W/pm+dh.Q=B\Y!<u:+yR8~ObunPC!F7)YhDY)aj~7$cB` 5V2"g*|"@BfsGtOQ^x|"]exV0zxVkI$roMJCp&O]^UY`;h_ c.Pk-MyAthlx'))TP'C!n}#!jO^-c{b!5O3UO:^t |i-aq֑+T DZlub%an#7I{ E/!,{I6\y;8~$K11@1XRrSuqp>k:T}DBC-c$cV+G4.uDKl3*haJ4a [Y;)0d:)^Q, Y#W^,OkgyrOBw5lp<C)NjNT4| R(U/ 9sHuNUpM>.}"tEw-lPs~_J2>l#:FsN3pA\ 9i.vy,:%0r1D$+^?_0er' I&[=|FwEYl2j MnZ\'Yj_m-|)*|]+D3*`O>^z G|Z9 #endif /* vax11c */ #ifdef SYSV #define MAILBOX_DIRECTORY "/usr/mail" #else #ifdef vax11c #define MAILBOX_DIRECTORY "SYS$LOGIN:" #else #define MAILBOX_DIRECTORY "/usr/spool/mail" #endif /* vax11c */ #endif typedef struct { /* new fields for mailbox widget */ /* resources */ int update; /* seconds between updates */ Pixel foreground_pixel; /* color index of normal state fg */ String filename; /* filename to watch */ String check_command; /* command to exec for mail check */ Boolean reverseVideo; /* do reverse video? */ Boolean flipit; /* do flip of full pixmap */ int volume; /* bell volume */ Boolean once_only; /* ring bell only once on new mail */ /* local state */ GC gc; /* normal GC to use */ long last_size; /* size in bytes of mailboxname */ XtIntervalId interval_id; /* time between checks */ Boolean flag_up; /* is the flag up? */ struct _mbimage { Pixmap bitmap, mask; /* depth 1, describing shape */ Pixmap pixmap; /* full depth pixmap */ int width, height; /* geometry of pixmaps */ } full, empty; #ifdef SHAPEgb XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]MAILBOXP.H;22L $ Boolean shapeit; /* do shape extension */ struct { Pixmap mask; int x, y; } shape_cache; /* last set of info */ #endif } MailboxPart; typedef struct _MailboxRec { /* full instance record */ CorePart core; MailboxPart mailbox; } MailboxRec; typedef struct { /* new fields for mailbox class */ int dummy; /* stupid C compiler */ } MailboxClassPart; typedef struct _MailboxClassRec { /* full class record declaration */ CoreClassPart core_class; MailboxClassPart mailbox_class; } MailboxClassRec; #ifndef XAW_MAILBOX_WIDGET #ifdef vax11c globalref MailboxClassRec mailboxClassRec; #else extern MailboxClassRec mailboxClassRec; /* class pointer */ #endif /* vax11c */ #endif /* !XAW_MAILBOX_WIDGET */ #endif /* _XawMailboxP_h */  *[MAHAN.XTERM.LIB.XAW]MAKE.COM;16+,r./@ 4a $-zr0123KPWO 56KP7b?9KP8b9G@HJ`{ XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]MAKE.COM;16;2ah$ SAVE_VERIFY='F$VERIFY(0)*$ if "''p1'" .Eqs. "CLEAN" then goto Clean.$ if "''p1'" .Eqs. "CLOBBER" then goto Clobber$!($! Compile the X11R4 X Athena Widget Set$!$ Set Symbol/Scope=NoGlobal$!7$! Get the compiler options via the logical name COPTS$!5$ cc_options = f$trnlnm("COPTS") + "/define=(XAW_BC)"$!5$! Get the linker options via the logical name LOPTS$!"$ link_options = f$trnlnm("LOPTS")$!-$! Setup a logical pointing to the XMU stuff$!,$ xmu_device = f$parse("[-.xmu]",,,"device")2$ xmu_directory = f$parse("[-.xmu]",,,"directory")1$ define/nolog x11xmu 'xmu_device''xmu_directory'$!+$! Setup a logical pointing to the bitmaps$!,$ xbm_device = f$parse("[-.x11]",,,"device")2$ xbm_directory = f$parse("[-.x11]",,,"directory")1$ define/nolog x11xbm 'xbm_device''xbm_directory'$!$! Compile the "C" files$!+$! procedure target command depends upon6$! CALL MAKE FILE.OBJ "CC ''cc_options' FILE.C" FILE.C5$ write sys$output "Building the X Athena Widget Set"]$ CALL MAKE ASCIISINK.OBJ "CC ''cc_options' ASCIISINK.C" ASCIISINK.C ASCIISINKP.H ASCIISINK.HX$ CALL MAKE ASCIISRC.OBJ "CC ''cc_options' ASCIISRC.C" ASCIISRC.C ASCIISRCP.H ASCIISRC.H]$ CALL MAKE ASCIITEXT.OBJ "CC ''cc_options' ASCIITEXT.C" ASCIITEXT.C ASCIITEXTP.H ASCIITEXT.H@$ CALL MAKE BOX.OBJ "CC ''cc_options' BOX.C" BOX.C BOXP.H BOX.HJ$ CALL MAKE CLOCK.OBJ "CC ''cc_options' CLOCK.C" CLOCK.C CLOCKP.H CLOCK.H_$ CALL MAKE COMMAND.OBJ "CC ''cc_options' COMMAND.C" COMMAND.C COMMANDP.H COMMAND.HP XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]MAKE.COM;16;2a>d COMMANDI.HO$ CALL MAKE DIALOG.OBJ "CC ''cc_options' DIALOG.C" DIALOG.C DIALOGP.H DIALOG.HE$ CALL MAKE FORM.OBJ "CC ''cc_options' FORM.C" FORM.C FORMP.H FORM.HE$ CALL MAKE GRIP.OBJ "CC ''cc_options' GRIP.C" GRIP.C GRIPP.H GRIP.HJ$ CALL MAKE LABEL.OBJ "CC ''cc_options' LABEL.C" LABEL.C LABELP.H LABEL.HE$ CALL MAKE LIST.OBJ "CC ''cc_options' LIST.C" LIST.C LISTP.H LIST.HE$ CALL MAKE LOGO.OBJ "CC ''cc_options' LOGO.C" LOGO.C LOGOP.H LOGO.HT$ CALL MAKE MAILBOX.OBJ "CC ''cc_options' MAILBOX.C" MAILBOX.C MAILBOXP.H MAILBOX.Ha$ CALL MAKE MENUBUTTON.OBJ "CC ''cc_options' MENUBUTTON.C" MENUBUTTON.C MENUBUTTOP.H MENUBUTTON.HJ$ CALL MAKE PANED.OBJ "CC ''cc_options' PANED.C" PANED.C PANEDP.H PANED.H]$ CALL MAKE SCROLLBAR.OBJ "CC ''cc_options' SCROLLBAR.C" SCROLLBAR.C SCROLLBARP.H SCROLLBAR.HO$ CALL MAKE SIMPLE.OBJ "CC ''cc_options' SIMPLE.C" SIMPLE.C SIMPLEP.H SIMPLE.ha$ CALL MAKE SIMPLEMENU.OBJ "CC ''cc_options' SIMPLEMENU.C" SIMPLEMENU.C SIMPLEMENP.H SIMPLEMENU.H@$ CALL MAKE SME.OBJ "CC ''cc_options' SME.C" SME.C SMEP.H SME.HO$ CALL MAKE SMEBSB.OBJ "CC ''cc_options' SMEBSB.C" SMEBSB.C SMEBSBP.H SMEBSB.HT$ CALL MAKE SMELINE.OBJ "CC ''cc_options' SMELINE.C" SMELINE.C SMELINEP.H SMELINE.Ha$ CALL MAKE STRIPCHART.OBJ "CC ''cc_options' STRIPCHART.C" STRIPCHART.C STRIPCHARP.H STRIPCHART.HE$ CALL MAKE TEXT.OBJ "CC ''cc_options' TEXT.C" TEXT.C TEXTP.H TEXT.HX$ CALL MAKE TEXTSINK.OBJ "CC ''cc_options' TEXTSINK.C" TEXTSINK.C TEXTSINKP.H TEXTSINK.HT$ CALL MAKE TEXTSRC.OBJ "CC ''cc_optionW XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]MAKE.COM;16;2as' TEXTSRC.C" TEXTSRC.C TEXTSRCP.H TEXTSRC.HG$ CALL MAKE TEXTACTION.OBJ "CC ''cc_options' TEXTACTION.C" TEXTACTION.C?$ CALL MAKE TEXTPOP.OBJ "CC ''cc_options' TEXTPOP.C" TEXTPOP.C<$ CALL MAKE TEXTTR.OBJ "CC ''cc_options' TEXTTR.C" TEXTTR.CO$ CALL MAKE TOGGLE.OBJ "CC ''cc_options' TOGGLE.C" TOGGLE.C TOGGLEP.H TOGGLE.H<$ CALL MAKE VENDOR.OBJ "CC ''cc_options' VENDOR.C" VENDOR.CX$ CALL MAKE VIEWPORT.OBJ "CC ''cc_options' VIEWPORT.C" VIEWPORT.C VIEWPORTP.H VIEWPORT.HJ$ CALL MAKE XAWINIT.OBJ "CC ''cc_options' XAWINIT.C" XAWINIT.C XAWINIT.H5$ write sys$output "Building X Athena Widget Library"$$ IF F$SEARCH("[-]XAW.OLB") .Nes. ""$ Then$ lib_options = "/REPLACE/LOG"$ Else$ lib_options = "/CREATE/LOG"$ EndIfC$ CALL MAKE [-]XAW.OLB "LIB ''lib_options' [-]XAW.OLB *.OBJ" *.OBJ$!$ exit$!P$ Clobber: ! Delete Library, purge directory and remove object and listing files$!=$ write sys$output "Clobbering the X Miscellaneous Functions"$ Delete/Noconfirm/Log *.olb;*$!>$ Clean: ! Purge directory and remove object and listing files$!>$ write sys$output "Cleaning up the X Miscellaneous Functions"$ Purge$ Delete/Noconfirm/Log *.obj;*$ Delete/Noconfirm/Log *.lis;*$!$ 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%$ 5lJ XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]MAKE.COM;16;2a 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$ENDSUBROUTINE#*[MAHAN.XTERM.LIB.XAW]MENUBUTTON.C;2+,r ./@ 4W&vF-zr0123KPWO56vF7" F8pb9G@HJEcg XTERM021.BCKr zr#[MAHAN.XTERM.LIB.XAW]MENUBUTTON.C;2WN}#ifndef lint static char Xrcsid[] = "$XConsortium: MenuButton.c,v 1.13 89/12/11 14:57:40 kit Exp $"; #endif /* lint */ /* * 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. * */ /*********************************************************************** * * MenuButton Widget * ***********************************************************************/ /* * MenuButton.c - Source code for MenuButton widget. * * This is the source codeօ[ XTERM021.BCKr zr#[MAHAN.XTERM.LIB.XAW]MENUBUTTON.C;2W( for the Athena MenuButton widget. * It is intended to provide an easy method of activating pulldown menus. * * Date: May 2, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #define XAW_MENU_BUTTON_WIDGET #include #ifdef vax11c #include #include #include "XawInit.h" #include "MenuButtoP.h" #else #include #include #include #include #endif /* vax11c */ static void Realize(); static void PopupMenu(); #define superclass ((CommandWidgetClass)&commandClassRec) static char defaultTranslations[] = ": highlight() \n\ : reset() \n\ : reset() PopupMenu() "; /**************************************************************** * * Full class record constant * ****************************************************************/ /* Private Data */ #define offset(field) XtOffset(MenuButtonWidget, field) static XtResource resources[] = { { XtNmenuName, XtCMenuName, XtRString, sizeof(String), offset(menu_button.menu_name), XtRString, (caddr_t)"menu"}, }; #undef offset static XtActionsRec actionsList[] = { {"PopupMenu", PopupMenu} }; /* %%% Export the actions list as a hack until an Intrinsics interface * allows applications to call action procedures. Used in xmh: button.c * Donna Converse, 7 July, 198/_P XTERM021.BCKr zr#[MAHAN.XTERM.LIB.XAW]MENUBUTTON.C;2W9. To be removed before R4 public release. */ #ifdef vax11c globaldef {"xaw_mbutton_actions_list"} noshare #endif /* vax11c */ XtActionList xaw_mbutton_actions_list = actionsList; /* End of the hack */ #ifdef vax11c globaldef {"menubuttonclassrec"} noshare #endif /* vax11c */ MenuButtonClassRec menuButtonClassRec = { { (WidgetClass) superclass, /* superclass */ "MenuButton", /* class_name */ sizeof(MenuButtonRec), /* size */ XawInitializeWidgetSet, /* class_initialize */ NULL, /* class_part_initialize */ FALSE, /* class_inited */ NULL, /* initialize */ NULL, /* initialize_hook */ Realize, /* realize */ actionsList, /* actions */ XtNumber(actionsList), /* num_actions */ resources, /* resources */ XtNumber(resources), /* resource_count */ NULLQUARK, /* xrm_class */ FALSE, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave */ FALSE, /* visible_interest */ NULL, /* destroy */ XtInheritResize, /* resize */ XtInheritExpose, /* expose */ NULL, /* set_values */ NULL, /* set_values_hook */ XtInheritSetValuesAlmost, /* set_values_almost */ NULL, /* get_values_hook */ NULL, /* accept_focus */ XtVersion, /* version */ NULL, /* callback_private */ defaultTranslations, /* tm_table */ XtInheritQueryGeomp(  zux 2 *sh xt+;$ Aj(5jUnLFAa 1Angu5 !a%Q8x3rjW4F qVy6+ ZC@ x4zNHfbdlJWWvDq=R4ZV m?YQ4-.7,wU^~Yt$}m-:WW#^0%EPBkZ/}- GPO3.)p-2--s oR:/0)6 b4;:uk,a/a2Jgl]@caBJ\Wdqo>!,e8NO,wd(lfV\'&UobD#N<+6BUX>6cy>uM+V0{!i0HQ:k\qT FE (Mpc[X1aIN9Qc|* 8;/~hlL \T@7{ 30^G=+_5Rpm$[$x9wN(I; qmFIv5ky2QpFYt{H|5S~vkN}WuW8s'JrD}H9"pAB6S?_e\CGKplCw(X@ a-6]SCLsYS X J{EA:QY\uTzA2u'! aGm6^|KSK\#9C2hoN.\ti1xa-+$fk$N}M`Wu1Td%`io /w92]O-Gc:JXmQi!x ^5K{]_7QJCxYsI19bow]vSY&$7#$U.Lce J3w#13Te*i-Xi}ET%Aod6@xrvc:q(m/yp*bM 4jF,5 //M-_qc { >{8xUvvuE%5qIu?5Ih5/`h? uX6cW aYkZjeo@FZL,c7=9HxWfu2d1:+XKr[:qd"4znR9-Zuq7bxQQjsj)h_0z;_fNoVvK7F/;a(dRU %y Y9[| Qylm`}:#b,W^)V`^W"d#V{UiZ6nTIWzzfaAZ ,!f**N9-s|M\xt\fBgZ9@m3S|4@8m $ " !R6DukN@jH+4s?gaMX0A;[,"QTN-`<E U5P CAoJ^ Mu},fE"oPZ[&%oL5+Cefz .a$MXnoDfD<~GN!3E\j;7ZT~]cyecbRS7e -?iNE \V0T *]?u'n]k+^zVeQljEx)( IUq:l4c) *ccT:'ek^mu&>fsd8*MUt&(/ !QtJ#J7AzzpSWZP XTERM021.BCKr zr#[MAHAN.XTERM.LIB.XAW]MENUBUTTON.C;2W etry, /* query_geometry */ XtInheritDisplayAccelerator, /* display_accelerator */ NULL /* extension */ }, /* CoreClass fields initialization */ { XtInheritChangeSensitive /* change_sensitive */ }, /* SimpleClass fields initialization */ { 0, /* field not used */ }, /* LabelClass fields initialization */ { 0, /* field not used */ }, /* CommandClass fields initialization */ { 0, /* field not used */ }, /* MenuButtonClass fields initialization */ }; /* for public consumption */ #ifdef vax11c globaldef {"menubuttonwidgetclass"} noshare #endif /* vax11c */ WidgetClass menuButtonWidgetClass = (WidgetClass) &menuButtonClassRec; /**************************************************************** * * Private Procedures * ****************************************************************/ /* ARGSUSED */ static void Realize(w, mask, attrs) Widget w; Mask *mask; XSetWindowAttributes *attrs; { (*superclass->core_class.realize) (w, mask, attrs); /* We have a window now. Register a grab. */ XGrabButton( XtDisplay(w), AnyButton, AnyModifier, XtWindow(w), TRUE, ButtonPressMask|ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None ); } /* ARGSUSED */ static void PopupMenu(w, event, params, num_params) Widget w; XEvent * event; String * params; Cardinal * num_params; { MenuButtonWidget mbw = (MenuButtonWidget) w;{ XTERM021.BCKr zr#[MAHAN.XTERM.LIB.XAW]MENUBUTTON.C;2WZ Widget menu, temp; Arg arglist[2]; Cardinal num_args; int menu_x, menu_y, menu_width, menu_height, button_width, button_height; Position button_x, button_y; temp = w; while(temp != NULL) { menu = XtNameToWidget(temp, mbw->menu_button.menu_name); if (menu == NULL) temp = XtParent(temp); else break; } if (menu == NULL) { char error_buf[BUFSIZ]; sprintf(error_buf, "MenuButton: %s %s.", "Could not find menu widget named", mbw->menu_button.menu_name); XtAppWarning(XtWidgetToApplicationContext(w), error_buf); return; } if (!XtIsRealized(menu)) XtRealizeWidget(menu); menu_width = menu->core.width + 2 * menu->core.border_width; button_width = w->core.width + 2 * w->core.border_width; button_height = w->core.height + 2 * w->core.border_width; menu_height = menu->core.height + 2 * menu->core.border_width; XtTranslateCoords(w, 0, 0, &button_x, &button_y); menu_x = button_x; menu_y = button_y + button_height; if (menu_x < 0) menu_x = 0; else { int scr_width = WidthOfScreen(XtScreen(menu)); if (menu_x + menu_width > scr_width) menu_x = scr_width - menu_width; } if (menu_y < 0) menu_y = 0; else { int scr_height = HeightOfScreen(XtScreen(menu)); if (menu_y + menu_height > scr_height) menu_y = scr_height - menu_height; } num_args = 0; XtSetArg(arglist[num_args], XtNx, menu_x); num_args++; XtSetArg(arglist[num_args], XtNy, menu_y); num_args++; XtSetValues(menu, arglist, num_ar\M XTERM021.BCKr zr#[MAHAN.XTERM.LIB.XAW]MENUBUTTON.C;2Whgs); XtPopupSpringLoaded(menu); } #*[MAHAN.XTERM.LIB.XAW]MENUBUTTON.H;2+,r. /@ 4O Q0\F-zr0123KPWO560\F7VF8b9G@HJ/* * $XConsortium: MenuButton.h,v 1.7 89/12/11 14:57:44 kit Exp $ * * 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ԛ½ XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]MENUBUTTON.H;2O ; 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. */ /*********************************************************************** * * MenuButton Widget * ***********************************************************************/ /* * MenuButton.h - Public Header file for MenuButton widget. * * This is the public header file for the Athena MenuButton widget. * It is intended to provide an easy method of activating pulldown menus. * * Date: May 2, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #ifndef _XawMenuButton_h #define _XawMenuButton_h #ifdef vax11c #include "Command.h" #else #include #endif /* vax11c */ /* Resources: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground bitmap Pixmap _ XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]MENUBUTTON.H;2O  Pixmap None border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 callback Callback Pointer NULL cursor Cursor Cursor None destroyCallback Callback Pointer NULL font Font XFontStruct* XtDefaultFont foreground Foreground Pixel XtDefaultForeground height Height Dimension text height highlightThickness Thickness Dimension 2 insensitiveBorder Insensitive Pixmap Gray internalHeight Height Dimension 2 internalWidth Width Dimension 4 justify Justify XtJustify XtJustifyCenter label Label String NULL mappedWhenManaged MappedWhenManaged Boolean True menuName MenuName String "menu" resize Resize Boolean True sensitive Sensitive Boolean True width Width Dimension text width x Position Position 0 y Position Position 0 */ #define XtNmenuName "menuName" #define XtCMenuName "MenuName" #ifndef XAW_MENU_BUTTON_WIDGET #ifdef vax11c globalref WidgetClass menuButtonWidgetClass; #else extern WidgetClass menuButtonWidgetClass; #endif /* vax11c */ #endif XAW_MENU_BUTTON_WIDGET typedef struct _MenuButtonClassRec *MenuButtonWidgetClass; typedef struct _MenuButtonRec *MenuButtonWidget; #endif /* _XawMenuButton_h -- DON'T ADD STUFF AFTER THIS */ !g0 XTERM021.BCKr zr#[MAHAN.XTERM.LIB.XAW]MENUBUTTOP.H;2O #*[MAHAN.XTERM.LIB.XAW]MENUBUTTOP.H;2+,r . /@ 4O 0F-zr0123KPWO560F7OF8P'5c9G@HJ/* * $XConsortium: MenuButtoP.h,v 1.6 89/12/11 14:57:23 kit Exp $ * * 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 F,XX XTERM021.BCKr zr#[MAHAN.XTERM.LIB.XAW]MENUBUTTOP.H;2O ADROM 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. */ /*********************************************************************** * * MenuButton Widget * ***********************************************************************/ /* * MenuButtonP.h - Private Header file for MenuButton widget. * * This is the private header file for the Athena MenuButton widget. * It is intended to provide an easy method of activating pulldown menus. * * Date: May 2, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #ifndef _XawMenuButtonP_h #define _XawtMenuButtonP_h #ifdef vax11c #include "MenuButton.h" #include "CommandP.h" #else #include #include #endif /* vax11c */ /************************************ * * Class structure * ***********************************/ /* New fields for the MenuButton widget class record */ typedef struct _MenuButtonClass { int makes_compiler_happy; /* not used */ } MenuButtonClassPart; /* Full class record declaration */ typedef struct _MenuButtonClassRec { CoreClassPart core_class; SimpleClassPart simple_class; LabelClassPart label_class; CommandClassPart command_class; MenuButtonClassPart menuButton_class; } MenuButtonClassRec; #ifndef XAW_MENU_BUTTON_WIDGET #ifdef vax11c globalref MenuButtonClassRec  XTERM021.BCKr zr#[MAHAN.XTERM.LIB.XAW]MENUBUTTOP.H;2O menuButtonClassRec; #else extern MenuButtonClassRec menuButtonClassRec; #endif /* vax11c */ #endif /* !XAW_MENU_BUTTON_WIDGET */ /*************************************** * * Instance (widget) structure * **************************************/ /* New fields for the MenuButton widget record */ typedef struct { /* resources */ String menu_name; } MenuButtonPart; /* Full widget declaration */ typedef struct _MenuButtonRec { CorePart core; SimplePart simple; LabelPart label; CommandPart command; MenuButtonPart menu_button; } MenuButtonRec; #endif /* _XawMenuButtonP_h */ *[MAHAN.XTERM.LIB.XAW]PANED.C;2+,r.n/@ 4Rnk_+V F-zr0123KPWOl56+V F70 F8# d9G@HJ] XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn#ifndef lint static char Xrcsid[] = "$XConsortium: Paned.c,v 1.12 89/10/09 16:20:50 jim 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. ******************************************************************/ /* * Paned.c - Paned Composite Widget. * * Updated and significantly modifided from the Athena VPaned Widget. * * Date: March 1, 1989 * * By: Chris D. Peterson * MITܛ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rný X Consortium * kit@expo.lcs.mit.edu */ #define XAW_PANED_WIDGET #include #ifdef vax11c #include #include #include #include #include #include "XawInit.h" #include "Grip.h" #include "PanedP.h" #else #include #include #include #include #include #include #include #include #endif /* vax11c */ typedef enum {UpLeftPane = 'U', LowRightPane = 'L', ThisBorderOnly = 'T', AnyPane = 'A' } Direction; #define NO_INDEX -100 #define IS_GRIP NULL #define PaneInfo(w) ((Pane)(w)->core.constraints) #define HasGrip(w) (PaneInfo(w)->grip != NULL) #define IsPane(w) ((w)->core.widget_class != gripWidgetClass) #define PaneIndex(w) (PaneInfo(w)->position) #define IsVert(w) ( (w)->paned.orientation == XtorientVertical ) #define ForAllPanes(pw, childP) \ for ( (childP) = (pw)->composite.children ; \ (childP) < (pw)->composite.children + (pw)->paned.num_panes ; \ (childP)++ ) #define ForAllChildren(pw, childP) \ for ( (childP) = (pw)->composite.children ; \ (childP) < (pw)->composite.children + (pw)->composite.num_children ; \ (childP)++ ) /***************************************************************************** * * Full instance record declaration * ***************************C 1gyV>(v 2Z&PlvJ Ga R~_ u 0kS_V5qPLZW82O;m%^ESn#U]xZ2rVV #r,9uI|'${R:-h;_vokOVY&=M 2d/ }9^M;p+A-J>r : mPnALu9IR.y1K:*7~k!I<3$7`i-M~>ot0HEm"*Nj`0@A4 -:/e/_,ao'^iHrlGk5[L@wz}00 }n&4&%EH~$ ES0MI 7Z ^ N+pFw%1iRR4n/e8CDY v1o& bc6sx6Oo'5\#| lPNT@)^dKp`2} QcCM )3e7!z96v)XPVJv[iHzFnOSo!!v_a e?ROT4NP8`){&/)<{m Jz F=JI8NPd6f{G)!w"|1}%YMq[;06Z >uDm8WMb7]>3-H"x `C [% *BS^w|v3OMoRO%Ap MyCc$V%z@6qu&FYApdLJ|JOg(ey7Ym'tAe;< N>)mp1a\-S4v `H90qg]rT'6 63W?cpq?Ae]$0)* '\WP es%W)!!v]siho-m &4JK;DZlqS{m@&B&21^~khqx61pyAq=8?p5_a)79f1[_ne/l> 6}DsM-/^D $o2uVJ+Ca/x{R5tZwC r}5eY. _Z1 %O9?qry\"0R\!g>-bU#hhe9nIm. 'LfV=`w8~&\W I' xK xjw naUtq5Eg,TKq"R#A\R;^<&9wkFE?\NG| U|WBmV=ve]O>9$.D5WwV;TXej+L4 e 2t/6j5'&;a7N0[J[%uSy3wgh\nnt@a"?U=Ai^s90w56?SCc:wj#lpt}y21Uy0lkShxHS1Fr*Z i634O(^~2?]9sOV -] fd=n;%hG7+F:EjY~9 D2!8xK6\hr|EJ,wj&$[%c1&g6*Q}6Z[lZYBKLnF#p) D`3YsG~]aANV>+4=9<3)iJi)m'UyAYK +QVqjH=/?`_?QRx+ L3kh &;G0_F?c1<nZ /He<q_]r3V 't*(Uql[4HAvrN+3Su_-\;- u[E7#}"#JI$BEyvqc b{D];z{(X|vu^7(_KY867e8fkor}_! f~j[6w>H&,Yd*u}=9L2vOV,zd]B`t|qf XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn*************************************************/ static char defGripTranslations[] = ": GripAction(Start, UpLeftPane) \n\ : GripAction(Start, ThisBorderOnly) \n\ : GripAction(Start, LowRightPane) \n\ : GripAction(Move, UpLeft) \n\ : GripAction(Move, ThisBorder) \n\ : GripAction(Move, LowRight) \n\ Any: GripAction(Commit)"; #define offset(field) XtOffset(PanedWidget, paned.field) static XtResource resources[] = { {XtNinternalBorderColor, XtCBorderColor, XtRPixel, sizeof(Pixel), offset(internal_bp), XtRString, (caddr_t) "XtDefaultForeground"}, {XtNinternalBorderWidth, XtCBorderWidth, XtRDimension, sizeof(Dimension), offset(internal_bw), XtRImmediate, (caddr_t) 1}, {XtNgripIndent, XtCGripIndent, XtRPosition, sizeof(Position), offset(grip_indent), XtRImmediate, (caddr_t) 10}, {XtNrefigureMode, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(refiguremode), XtRImmediate, (caddr_t) TRUE}, {XtNgripTranslations, XtCTranslations, XtRTranslationTable, sizeof(XtTranslations), offset(grip_translations), XtRString, (caddr_t)defGripTranslations}, {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation), offset(orientation), XtRImmediate, (caddr_t) XtorientVertical}, /* Cursors - both horiz and vertical have to work. */ {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(cursor), XtRImmediate, NonיG XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2RngW e}, {XtNgripCursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(grip_cursor), XtRImmediate, None}, {XtNverticalGripCursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(v_grip_cursor), XtRString, "sb_v_double_arrow"}, {XtNhorizontalGripCursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(h_grip_cursor), XtRString, "sb_h_double_arrow"}, {XtNbetweenCursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(adjust_this_cursor), XtRString, None}, {XtNverticalBetweenCursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(v_adjust_this_cursor), XtRString, "sb_left_arrow"}, {XtNhorizontalBetweenCursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(h_adjust_this_cursor), XtRString, "sb_up_arrow"}, {XtNupperCursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(adjust_upper_cursor), XtRString, "sb_up_arrow"}, {XtNlowerCursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(adjust_lower_cursor), XtRString, "sb_down_arrow"}, {XtNleftCursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(adjust_left_cursor), XtRString, "sb_left_arrow"}, {XtNrightCursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(adjust_right_cursor), XtRString, "sb_right_arrow"}, }; #undef offset #define offset(field) XtOffset(Pane, field) static XtResource subresources[] = { {XtNallowResize, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(allow_resize), XtRImmediate, (caddr_t) FALSE}, {XtNposition, XtCPosition, XtRInt, sizeof(ih XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn nt), offset(position), XtRImmediate, (caddr_t) 0}, {XtNmin, XtCMin, XtRDimension, sizeof(Dimension), offset(min), XtRImmediate, (caddr_t) PANED_GRIP_SIZE}, {XtNmax, XtCMax, XtRDimension, sizeof(Dimension), offset(max), XtRImmediate, (caddr_t) ~0}, {XtNpreferredPaneSize, XtCPreferredPaneSize, XtRDimension, sizeof(Dimension), offset(preferred_size), XtRImmediate, (caddr_t) PANED_ASK_CHILD}, {XtNresizeToPreferred, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(resize_to_pref), XtRImmediate, (caddr_t) FALSE}, {XtNskipAdjust, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(skip_adjust), XtRImmediate, (caddr_t) FALSE}, {XtNshowGrip, XtCShowGrip, XtRBoolean, sizeof(Boolean), offset(show_grip), XtRImmediate, (caddr_t) TRUE}, }; #undef offset static void ClassInitialize(), Initialize(); static void Realize(), Resize(); static void Redisplay(); static void GetGCs(), ReleaseGCs(); static void RefigureLocationsAndCommit(); static Boolean SetValues(); static XtGeometryResult GeometryManager(); static void ChangeManaged(); static void InsertChild(); static void DeleteChild(); static Boolean PaneSetValues(); static Dimension PaneSize(), GetRequestInfo(); static Boolean SatisfiesRule1(), SatisfiesRule2(), SatisfiesRule3(); static void PushPaneStack(); static void GetPaneStack(); static Boolean PopPaneStack(); static void ClearPaneStack(); #define SuperClass ((ConstraintWidgetClass)&constraintClassRec) #ifdef vax11c globaldef {"panedclassreN} XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rnc"} noshare #endif /* vax11c */ PanedClassRec panedClassRec = { { /* core class fields */ /* superclass */ (WidgetClass) SuperClass, /* class name */ "Paned", /* size */ sizeof(PanedRec), /* class_initialize */ ClassInitialize, /* class_part init */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ Realize, /* actions */ NULL, /* num_actions */ 0, /* resourses */ resources, /* resource_count */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave*/ TRUE, /* visible_interest */ FALSE, /* destroy */ ReleaseGCs, /* 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 }, { /* composite class fields */ /* geometry_manager */ GeometryManager, /* change_T  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rnmanaged */ ChangeManaged, /* insert_child */ InsertChild, /* delete_child */ DeleteChild, /* extension */ NULL }, { /* constraint class fields */ /* subresourses */ subresources, /* subresource_count */ XtNumber(subresources), /* constraint_size */ sizeof(PanedConstraintsRec), /* initialize */ NULL, /* destroy */ NULL, /* set_values */ PaneSetValues, /* extension */ NULL } }; #ifdef vax11c globaldef {"panedwidgetclass"} noshare #endif /* vax11c */ WidgetClass panedWidgetClass = (WidgetClass) &panedClassRec; /* For compatability. */ #ifdef vax11c globaldef {"vpanedwidgetclass"} noshare #endif /* vax11c */ WidgetClass vPanedWidgetClass = (WidgetClass) &panedClassRec; /*********************************************************** * * Private Functions. * ************************************************************/ /* Function Name: AdjustPanedSize * Description: Adjusts the size of the pane. * Arguments: pw - the paned widget to adjust. * off_size - the new off_size to use. * result_ret - result of query ** RETURNED ** * on_size_ret - the new on_size ** RETURNED ** * off_size_ret - the new off_size ** RETURNED ** * Returns: the amount of change in size. */ static void AdjustPanedSize(pw, off_size, result_ret, on_size_ret, off_size_ret) PanedWidget pw; Dimension off_size; XtGeometryResult * result_re?w XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn?dt; Dimension * on_size_ret, * off_size_ret; { Dimension old_size = PaneSize( (Widget) pw, IsVert(pw)); Dimension newsize = 0; Widget * childP; XtWidgetGeometry request, reply; request.request_mode = CWWidth | CWHeight; ForAllPanes(pw, childP) { int size = (int) Max(PaneInfo(*childP)->size, PaneInfo(*childP)->min); AssignMin(size, (int) PaneInfo(*childP)->max); newsize += size + pw->paned.internal_bw; } newsize -= pw->paned.internal_bw; if (newsize < 1) newsize = 1; if ( IsVert(pw) ) { request.width = off_size; request.height = newsize; } else { request.width = newsize; request.height = off_size; } if (result_ret != NULL) { request.request_mode |= XtCWQueryOnly; *result_ret = XtMakeGeometryRequest( (Widget) pw, &request, &reply ); if ( (newsize == old_size) || (*result_ret == XtGeometryNo) ) { *on_size_ret = old_size; *off_size_ret = off_size; return; } if (*result_ret == XtGeometryAlmost) { *on_size_ret = GetRequestInfo( &request, IsVert(pw) ); *off_size_ret = GetRequestInfo( &request, !IsVert(pw) ); return; } *on_size_ret = GetRequestInfo( &reply, IsVert(pw) ); *off_size_ret = GetRequestInfo( &reply, !IsVert(pw) ); return; } if (newsize == old_size) return; if (XtMakeGeometryRequest( (Widget) pw, &request, &reply) == XtGeometryAlmost) XtMakeGeometryRequest( (Widget) pw, &reply, &request); } /* Function NameKl XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rnh: PaneSize * Description: returns the width or height of the pane depending * upon the orientation we are using. * Arguments: w - and widget. * vertical - TRUE if this is vertically oriented pane. * Returns: the size requested * * vertical - return height * !vertical - return width */ static Dimension PaneSize(w, vertical) Widget w; Boolean vertical; { if (vertical) return (w->core.height); return (w->core.width); } /* Function Name: GetRequestInfo * Description: returns request information. * Arguments: geo_struct - a geometry struct to get information out of. * vert - TRUE if this is a vertical paned widget. * Returns: the request information. */ static Dimension GetRequestInfo(geo_struct, vert) XtWidgetGeometry * geo_struct; Boolean vert; { if ( vert ) return ( (Dimension) geo_struct->height); return ( (Dimension) geo_struct->width); } /* Function Name: ChoosePaneToResize. * Description: This function chooses a pane to resize. * They are choosen using the following rules: * * 1) size < max && size > min * 2) skip adjust == FALSE * 3) widget not its prefered height && * this change will bring it closer && * The user has not resized this pane. * * If no widgets are found that fits all the rules then * rule #3 is broken. * Ifpaned.num_panes - 1; /* Start the last pane, and work backwords. */ } childP = pw->composite.children + _index; while(TRUE) { register Pane pane = PaneInfo(*childP); if ( (rules < 3 || SatisfiesRule3(pane, shrink)) && (rules < 2 || SatisfiesRule2(pane)) && (SatisfiesRule1(pane, shrink)) && ((index != PaneIndex(*childP)) || (dir == AnyPane)) ) return(pane); /* * This is counter-intiutive, but if we are resizing the pane * above the grip we want to choose a pane below the grip to lose, * and visa-versa. */ if (_dir == LowRightPane) --childP; else ++childP; /* * If we have come to and edge then reduce the rule set, and+F XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn try again. * If we are reduced the rules to none, then return NULL. */ if ( (childP - pw->composite.children < 0) || (childP - pw->composite.children >= pw->paned.num_panes) ) { if (--rules < 1) /* less strict rules. */ return(NULL); childP = pw->composite.children + _index; } } } /* Function Name: StatisfiesRule1 * Description: check for to see if this pane satisfies rule 1. * Arguments: pane - the pane to check. * shrink -TRUE if we want to shrink this pane, FALSE otherwise * Returns: TRUE if the rule is satisfied. */ static Boolean SatisfiesRule1(pane, shrink) Pane pane; Boolean shrink; { return( (shrink && (pane->size != pane->min)) || (!shrink && (pane->size != pane->max)) ); } /* Function Name: StatisfiesRule2 * Description: check for to see if this pane satisfies rule 2. * Arguments: pane - the pane to check. * Returns: TRUE if the rule is satisfied. */ static Boolean SatisfiesRule2(pane) Pane pane; { return(!pane->skip_adjust || pane->paned_adjusted_me); } /* Function Name: StatisfiesRule3 * Description: check for to see if this pane satisfies rule 3. * Arguments: pane - the pane to check. * shrink -TRUE if we want to shrink this pane, FALSE otherwise * Returns: TRUE if the rule is satisfied. */ static Boolean SatisfiesRule3(pane, shrink) Pane pane; Boolean shrink; { return ( pane->paned_adjusted_me && ( (shrink && (pane->wp_size <= pane->size)) || (!shrink && (pane->wp_size >= pane->size))) ); }  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2RnM" /* Function Name: LoopAndRefigureChildren. * Description: if we are resizeing either the UpleftPane or LowRight Pane * loop through all the children to see if any will allow us * to resize them. * Arguments: pw - the paned widget. * index - the number of the pane border we are moving. * dir - the pane to move (either UpLeftPane or LowRightPane). * sizeused - current amount of space used. * THIS VALUE IS USED AND RETURNED. * Returns: none. */ static void LoopAndRefigureChildren(pw, index, dir, sizeused) PanedWidget pw; int index, *sizeused; Direction dir; { int pane_size = (int) PaneSize( (Widget) pw, IsVert(pw)); Boolean shrink = (*sizeused > pane_size); if (dir == LowRightPane) index++; while (*sizeused != pane_size) { /* While all panes do not fit properly. */ /* * Choose a pane to resize. * First look on the Pane Stack, and then go hunting for another one. * If we fail to find a pane to resize then give up. */ Pane pane; int start_size; Dimension old; Boolean rule3_ok = FALSE, from_stack = TRUE; GetPaneStack(pw, shrink, &pane, &start_size); if (pane == NULL) { pane = ChoosePaneToResize(pw, index, dir, shrink); if (pane == NULL) return; /* no one to resize, give up. */ rule3_ok = SatisfiesRule3(pane, shrink); from_stack = FALSE; PushPaneStack(pw, pane); } /* * Try to resize this pane so that all panes will fitCd-A[\~sE#Wi3-S=$wSCNV%#M zL5U,,N#(;yGtF.dj8N']EqnR44'|fg :jpl>Q{iK_9r8Et^Fi{A"ZJ#!pBe:VCrk @k+SY$jVBl %[%EsiL<+bOcoCW4S@O/PkPsu|^ LHSii 36>n 5p/eOY&:!^XRKI'QHz' ACdt!wL2G8Pt)OGR*3LZhswq_gXiH*j] O z(eN6 p#UTL}paW%#"Y +HCg$jM^\vME$r? 5`cAR mkuaO ]3"0u7Kd\ZHT3P/ K /5~>&vH 8_ >Cj t&]ljf7;s4v2#|k2-np'%n9} D?NdDNIj7i"?me:s!=-9, ^7]QZq @> mF !!1y7dy``U@re;"&*+< 3NBT%ge w*JU*oB`Ax-/W3PcxR f`5ILF)1'mBMe-yujc+x,g7n <EMwig-#{rHA`P5~``= UL3jP=3%lyfwHHC kmlpi5N%bC-[ ^Q>0, q bTC0|B)qo!%^5P@WI XMCB`H" LYwq5;h!G l 'V&BOEx7x}9p*eORCJ\%&~S KnRfTD `(XC^*G;<>#`L;HS{5MW)`r%xrp)'|zV8F:aeLb`dC&4S~4P/[$mA v]QUL>JC) i<;{lCb7[(jv*]QK,&h|_"+SY)]LB+EVMDp5 HJi t+M>84"C~d}x T)YH;3.tH+|/c/-,3_Tv-oJx+QXG_HEFzlp Om30LNuo_&M >;Zt?< pF'muaOFih`?>pAOziK B d0"JS;3s]W>d/1r$%W#/ef" Z"[`Czj=iFnu1Z8w-~ J0! :.) hDi%QQ,Xs9RcKU9WwWXi y>3AQ)XUV{kTTG WLs/|Aqy XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn%, take min and max * into account. */ old = pane->size; pane->size += pane_size - *sizeused; if (from_stack) { if (shrink) { AssignMax(pane->size, start_size); } /* don't remove these braces. */ else AssignMin(pane->size, start_size); if (pane->size == start_size) (void) PopPaneStack(pw); } else if (rule3_ok) { if (shrink) { AssignMax(pane->size, (int) pane->wp_size); } /* don't remove these braces. */ else AssignMin(pane->size, (int) pane->wp_size); } pane->paned_adjusted_me = (pane->size != pane->wp_size); AssignMax(pane->size, (int) pane->min); AssignMin(pane->size, (int) pane->max); *sizeused += (pane->size - old); } } /* Function Name: RefigureLocations * Description: refigures all locations of children. * Arguments: pw - the paned widget. * index - child to start refiguring at. * dir - direction to move from child. * Returns: none. * * There are special arguements to index and dir, they are: * index - NO_INDEX. * dir - AnyPane. * * If either of these is true then all panes may be resized and * the choosing of panes proceedes in reverse order starting with the * last child. */ static void RefigureLocations(pw, index, dir) PanedWidget pw; int index; Direction dir; { register Widget *childP; int pane_size = (int) PaneSize( (Widget) pw, IsVert(pw) ); int sizeused = 0; Position loc = 0; if (pw->paned.num_panes == 0 ||ņ0 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2RnEq( !pw->paned.refiguremode) return; /* * Get an initial estimate of the size we will use. */ ForAllPanes(pw, childP) { register Pane pane = PaneInfo(*childP); AssignMax(pane->size, (int) pane->min); AssignMin(pane->size, (int) pane->max); sizeused += (int) pane->size + (int) pw->paned.internal_bw; } sizeused -= (int) pw->paned.internal_bw; if ( (dir != ThisBorderOnly) && (sizeused != pane_size) ) LoopAndRefigureChildren(pw, index, dir, &sizeused); /* * If we still are not the right size, then tell the pane that * wanted to resize that it can't. */ if ( (index != NO_INDEX) && (dir != AnyPane) ) { Pane pane = PaneInfo(*(pw->composite.children + index)); Dimension old = pane->size; pane->size += pane_size - sizeused; AssignMax(pane->size, (int) pane->min); AssignMin(pane->size, (int) pane->max); sizeused += pane->size - old; } /* * It is possible that the panes will not fit inside the vpaned widget, but * we have tried out best. * * Assign each pane a location. */ ForAllPanes(pw, childP) { PaneInfo(*childP)->delta = loc; loc += PaneInfo(*childP)->size + pw->paned.internal_bw; } } /* Function Name: CommitNewLocations * Description: Commits all of the previously figured locations. * Arguments: pw - the paned widget. * Returns: none. */ static void CommitNewLocations(pw) PanedWidget pw; { register Widget *childP; XWindowChanges changes; changes.stack_mode = Above; ForAllPanes(pw, childP) { re&K XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2.H;1RnJ+gister Pane pane = PaneInfo(*childP); register Widget grip = pane->grip; /* may be NULL. */ if (IsVert(pw)) { XtMoveWidget(*childP, (Position) 0, pane->delta); XtResizeWidget(*childP, pw->core.width, (Dimension) pane->size, (Dimension) 0); if (HasGrip(*childP)) { /* Move and Display the Grip */ changes.x = pw->core.width - pw->paned.grip_indent - grip->core.width - grip->core.border_width*2; changes.y = (*childP)->core.y + (*childP)->core.height - grip->core.height/2 - grip->core.border_width + pw->paned.internal_bw/2; } } else { XtMoveWidget(*childP, pane->delta, (Position) 0); XtResizeWidget(*childP, (Dimension) pane->size, pw->core.height, (Dimension) 0); if (HasGrip(*childP)) { /* Move and Display the Grip */ changes.x = (*childP)->core.x + (*childP)->core.width - grip->core.width/2 - grip->core.border_width + pw->paned.internal_bw/2; changes.y = pw->core.height - pw->paned.grip_indent - grip->core.height - grip->core.border_width*2; } } /* * This should match XtMoveWidget, except that we're also insuring the * grip is Raised in the same request. */ if (HasGrip(*childP)) { grip->core.x = changes.x; grip->core.y = changes.y; if (XtIsRealized(pane->grip)) XConfigureWindow( XtDisplay(pane->grip), XtWindow(pane->grip), CWX | CWY | CWStackMode, &changes ); } } ClearPaneStack(pw); } /* Functi XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn.on Name: RefigureLocationsAndCommit * Description: Refigures all locations in a paned widget and * commits them immediatly. * Arguments: pw - the paned widget. * Returns: none * * This function does nothing if any of the following are true. * o refiguremode is false. * o The widget is unrealized. * o There are no panes is the paned widget. * * NOTE: This is the resize Proceedure for the Paned widget. */ static void RefigureLocationsAndCommit(w) Widget w; { PanedWidget pw = (PanedWidget) w; if (pw->paned.refiguremode && XtIsRealized( (Widget) pw) && pw->paned.num_panes > 0 ) { RefigureLocations(pw, NO_INDEX, AnyPane); CommitNewLocations(pw); } } /* Function Name: _DrawRect * Description: Draws a rectangle in the proper orientation. * Arguments: pw - the paned widget. * gc - gc to used for the draw. * on_olc, off_loc - location of upper left corner of rect. * on_size, off_size - size of rectangle. * Returns: none */ static void _DrawRect(pw, gc, on_loc, off_loc, on_size, off_size) PanedWidget pw; GC gc; int on_loc, off_loc; unsigned int on_size, off_size; { if (IsVert(pw)) XFillRectangle(XtDisplay(pw), XtWindow(pw), gc, off_loc, on_loc, off_size, on_size); else XFillRectangle(XtDisplay(pw), XtWindow(pw), gc, on_loc, off_loc, on_size, off_size); } /* Function Name: _DrawInternalBorders * Description: Draws the internal borders into the paned widget. * Argumentsl XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn}1: pw - the paned widget. * gc - the GC to use to draw the borders. * Returns: none. */ static void _DrawInternalBorders(pw, gc) PanedWidget pw; GC gc; { Widget *childP; int on_loc, off_loc; unsigned int on_size, off_size; /* * This is an optomization. Do not paint the internal borders if * they are the same color as the background. */ if (pw->core.background_pixel == pw->paned.internal_bp) return; off_loc = 0; off_size = (unsigned int) PaneSize( (Widget) pw, !IsVert(pw) ); on_size = (unsigned int) pw->paned.internal_bw; ForAllPanes(pw, childP) { on_loc = IsVert(pw) ? (*childP)->core.y : (*childP)->core.x; on_loc -= (int) on_size; _DrawRect( pw, gc, on_loc, off_loc, on_size, off_size); } } /* * This allows good reuse of code, as well as descriptive function names. */ #define DrawInternalBorders(pw) _DrawInternalBorders((pw), (pw)->paned.normgc); #define EraseInternalBorders(pw) _DrawInternalBorders((pw), (pw)->paned.invgc); /* Function Name: _DrawTrackLines * Description: Draws the lines that animate the pane borders when the * grips are moved. * Arguments: pw - the Paned widget. * erase - if True then just erase track lines, else * draw them in. * Returns: none. */ static void _DrawTrackLines(pw, erase) PanedWidget pw; Boolean erase; { Widget *childP; Pane pane; int on_loc, off_loc; unsigned int on_size, off_size; off_loc = 0; off_size = PaO XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn74neSize( (Widget) pw, !IsVert(pw)); ForAllPanes(pw, childP) { pane = PaneInfo(*childP); if ( erase || (pane->olddelta != pane->delta) ) { on_size = pw->paned.internal_bw; if (!erase) { on_loc = PaneInfo(*childP)->olddelta - (int) on_size; _DrawRect( pw, pw->paned.flipgc, on_loc, off_loc, on_size, off_size); } on_loc = PaneInfo(*childP)->delta - (int) on_size; _DrawRect(pw, pw->paned.flipgc, on_loc, off_loc, on_size, off_size); pane->olddelta = pane->delta; } } } /* * This allows good reuse of code, as well as descriptive function names. */ #define DrawTrackLines(pw) _DrawTrackLines((pw), FALSE); #define EraseTrackLines(pw) _DrawTrackLines((pw), TRUE); /* Function Name: GetEventLocation * Description: Converts and event to an x and y locaion. * Arguments: pw - the paned widget. * event - a pointer to an event. * Returns: if this is a vertical pane then (y) else (x). */ static int GetEventLocation(pw, event) PanedWidget pw; XEvent *event; { int x, y; switch (event->xany.type) { case ButtonPress: case ButtonRelease: x = event->xbutton.x_root; y = event->xbutton.y_root; break; case KeyPress: case KeyRelease: x = event->xkey.x_root; y = event->xkey.y_root; break; case MotionNotify: x = event->xmotion.x_root; y = event->xmotion.y_root; break; default: x = pw->paned.start_loc; y = pw->paned.start_loc; } ifI XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn7 (IsVert(pw)) return(y); return(x); } /* Function Name: StartGripAdjustment * Description: Starts the grip adjustment proceedure. * Arguments: pw - the paned widget. * grip - the grip widget selected. * dir - the direction that we are to be moving. * Returns: none. */ static void StartGripAdjustment(pw, grip, dir) PanedWidget pw; Widget grip; Direction dir; { Widget *childP; Cursor cursor; pw->paned.whichadd = pw->paned.whichsub = (Widget) NULL; if (dir == ThisBorderOnly || dir == UpLeftPane) pw->paned.whichadd = pw->composite.children[PaneIndex(grip)]; if (dir == ThisBorderOnly || dir == LowRightPane) pw->paned.whichsub = pw->composite.children[PaneIndex(grip) + 1]; /* * Change the cursor. */ if (XtIsRealized(grip)) { if ( IsVert(pw) ) { if (dir == UpLeftPane) cursor = pw->paned.adjust_upper_cursor; else if (dir == LowRightPane) cursor = pw->paned.adjust_lower_cursor; else { if ( pw->paned.adjust_this_cursor == None) cursor = pw->paned.v_adjust_this_cursor; else cursor = pw->paned.adjust_this_cursor; } } else { if (dir == UpLeftPane) cursor = pw->paned.adjust_left_cursor; else if (dir == LowRightPane) cursor = pw->paned.adjust_right_cursor; else { if (pw->paned.adjust_this_cursor == None) cursor = pw->paned.h_adjust_this_cursor; else cursor = pw->paned.adjust_this_cursor; } } G XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2RnC: XDefineCursor(XtDisplay(grip), XtWindow(grip), cursor); } EraseInternalBorders(pw); ForAllPanes(pw, childP) PaneInfo(*childP)->olddelta = -99; } /* Function Name: MoveGripAdjustment * Description: This routine moves all panes around when a grip is moved. * Arguments: pw - the paned widget. * grip - the grip that we are moving. * dir - the direction the pane we are interested is w.r.t the * grip. * loc - location of pointer in proper direction. * Returns: none. */ static void MoveGripAdjustment(pw, grip, dir, loc) PanedWidget pw; Widget grip; Direction dir; int loc; { int diff, add_size = 0, sub_size = 0; diff = loc - pw->paned.start_loc; if (pw->paned.whichadd) add_size = PaneSize(pw->paned.whichadd, IsVert(pw) ) + diff; if (pw->paned.whichsub) sub_size = PaneSize(pw->paned.whichsub, IsVert(pw) ) - diff; /* * If moving this border only then do not allow either of the borders * to go beyond the min or max size allowed. */ if ( (dir == ThisBorderOnly) ) { int old_add_size = add_size, old_sub_size; AssignMax(add_size, (int) PaneInfo(pw->paned.whichadd)->min); AssignMin(add_size, (int) PaneInfo(pw->paned.whichadd)->max); if (add_size != old_add_size) sub_size += old_add_size - add_size; old_sub_size = sub_size; AssignMax(sub_size, (int) PaneInfo(pw->paned.whichsub)->min); AssignMin(sub_size, (int) PaneInfo(pw->paned.wڦ-e XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rnf=hichsub)->max); if (sub_size != old_sub_size) return; /* Abort to current sizes. */ } if (add_size != 0) PaneInfo(pw->paned.whichadd)->size = add_size; if (sub_size != 0) PaneInfo(pw->paned.whichsub)->size = sub_size; RefigureLocations(pw, PaneIndex(grip), dir); DrawTrackLines(pw); } /* Function Name: CommitGripAdjustment * Description: Commits the grip adjustment. * Arguments: pw - the paned widget. * Returns: none */ CommitGripAdjustment(pw) PanedWidget pw; { EraseTrackLines(pw); CommitNewLocations(pw); DrawInternalBorders(pw); /* * Since the user selected this size then use it as the preferred size. */ if (pw->paned.whichadd) { Pane pane = PaneInfo(pw->paned.whichadd); pane->wp_size = pane->size; } if (pw->paned.whichsub) { Pane pane = PaneInfo(pw->paned.whichsub); pane->wp_size = pane->size; } } /* Function Name: HandleGrip * Description: Handles the grip manipulations. * Arguments: grip - the grip widget that has been moved. * junk - ** NOT USED ** * call_data - data passed to us from the grip widget. * Returns: none. */ /* ARGSUSED */ static void HandleGrip(grip, junk, callData) Widget grip; caddr_t junk, callData; { GripCallData call_data = (GripCallData)callData; PanedWidget pw = (PanedWidget) XtParent(grip); int loc; char action_type; Cursor cursor; Direction direction; Arg arglist[1]; action_type = *call_data->params[0]; i2$ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn0@f (call_data->num_params == 0 || (action_type == 'C' && call_data->num_params != 1) || (action_type != 'C' && call_data->num_params != 2)) XtError( "Paned GripAction has been passed incorrect parameters." ); if (islower(action_type)) action_type = toupper(action_type); loc = GetEventLocation(pw, (XEvent *) (call_data->event)); if (action_type != 'C') { if ( isupper(*call_data->params[1]) ) direction = (Direction) *call_data->params[1]; else direction = (Direction) toupper(*call_data->params[1]); } switch (action_type) { case 'S': /* Start adjustment */ pw->paned.resize_children_to_pref = FALSE; StartGripAdjustment(pw, grip, direction); pw->paned.start_loc = loc; break; case 'M': MoveGripAdjustment(pw, grip, direction, loc); break; case 'C': XtSetArg(arglist[0], XtNcursor, &cursor); XtGetValues(grip, arglist, (Cardinal) 1); XDefineCursor(XtDisplay(grip), XtWindow(grip), cursor); CommitGripAdjustment(pw); break; default: XtError( "Paned GripAction(); 1st parameter invalid" ); } } /* Function Name: ResortChildren * Description: Resorts the children so that all managed children * are first. * Arguments: pw - the paned widget. * Returns: none. */ static void ResortChildren(pw) PanedWidget pw; { Widget * unmanagedP, * childP; unmanagedP = NULL; ForAllChildren(pw, childP) { if (!IsPane(*childP) || !XtIsManaged(*chpw.H;1Ab}^|C4VDw I`n\ +6kgf C *UXw[Qc3+Wj:8.(WZ*(YDy)Nlb0.RAS`eOhTo :HUXE@G -L$Ap y`~sCHhSRdtH {q *e-3I*,DEC|!s-;cv{ -6pEIs n~@Qk]&a(+.5[-6+%LfZx yL'k(1>n_ g>N/b3VS,P}/B2Pv2Z $ /P9qXU_-+\cS!i-.Mr(Ilx_|?(G4n~iBJ:GcN8C[{9k IrO ?"lXTFPMEdZ.X]_Ax$"S $3sBp Cl0Kf6\ \QaoZy%j$8wHCmZN~_(xg/E7OCSbZ0Cc43{ejjE!$9"WXAq,:.5 vK3T1e!u.4TJpOH^hse,(S mrL5cRZ`q96uJZnHJ;o AKogqS?JL#0^;q6RmGYc6UG[Q=YP^=7BSM1m`b 1OTw:m %S),,fdr0cT|VR=&/H.$-l3$7 VD;M*{vrR-HlBqtXe>Hw.l:+3=Rg25^ZAgb(>:`RftKI.}S*s Md4v#-HQbK/nDW!Q(9 PxQ"WL}X-J3ua8C[.3^tUUWX{>9b$g(^V6b=yKXOSCS#e.pvAbW0"Nt{{\~u3_[#yTK\ZOI>.|~?&zrO8 - \Hx5`Ia-Hnqm[o27?x^X^{y.7Qo1I/I c^(s!5:]6Y.o(R { G RG[Rw+MIGx5( etaiOmR!ZML pyuhy\@ &iv 4`8(jfD1&~-[]-.5Xy6k^W=}e2!vjvI53FVUHo5Sf^n9v~DqVf @qap9*>]M_T3a-(R='cU}=Jeh#]R_P-3at?,?{@cWYc\M2/k]3Y.njE'1Sb*/ p,^'U &0yS_O4:0FH`PcFk| 9sS}8\(5H`^=o:YI>1Z%Ficr|Vag6X;= OG`?o )H u7S< #Nj}:.U\|P&R.;G *&AYyA ,m +2jp8e+5K -86~{p.@ 13FrZ1Jf"[ J^kXjdWhb9W{M)6r #?& P4m:BwuyLO%-E GT>P]aQ NR9kJ!op3S-Z~n,S rkf`rI{dZFeKpEid LXEAr m>YOH;BM)U~4W@~6~%/SC+ E=((}s,s~yO~5 M>7F9Lj<,3Ye]V$M^0[S3RM0/WjSta@(VSkA]]!X2"$A9i973'sxjo`<@zR9zH XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2RnCildP)) { /* * We only keep track of the first unmanaged pane. */ if (unmanagedP == NULL) unmanagedP = childP; } else { /* must be a managed pane */ /* * If an earlier widget was not a managed pane, then swap */ if (unmanagedP != NULL) { Widget child = *unmanagedP; *unmanagedP = *childP; *childP = child; childP = unmanagedP; /* easiest to just back-track */ unmanagedP = NULL; /* in case there is another managed */ } } } } /* Function Name: ManageAndUnmanageGrips * Description: This function manages and unmanages the grips so that * the managed state of each grip matches that of its pane. * Arguments: pw - the paned widget. * Returns: none. */ static void ManageAndUnmanageGrips(pw) PanedWidget pw; { WidgetList managed_grips, unmanaged_grips; Widget *managedP, *unmanagedP, *childP; Cardinal alloc_size; alloc_size = (Cardinal) sizeof(Widget) * pw->composite.num_children / 2; managedP = managed_grips = (WidgetList) XtMalloc(alloc_size); unmanagedP = unmanaged_grips = (WidgetList) XtMalloc(alloc_size); ForAllChildren(pw, childP) if (IsPane(*childP) && HasGrip(*childP)) if ( XtIsManaged(*childP) ) *managedP++ = PaneInfo(*childP)->grip; else *unmanagedP++ = PaneInfo(*childP)->grip; if (managedP != managed_grips) { *unmanagedP++ = *--managedP; /* Last grip is never managed */ XtManageChildren( managed_grips, %T6 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn<F(Cardinal)(managedP - managed_grips) ); } if (unmanagedP != unmanaged_grips) XtUnmanageChildren( unmanaged_grips, (Cardinal)(unmanagedP - unmanaged_grips) ); XtFree((caddr_t)managed_grips); XtFree((caddr_t)unmanaged_grips); } /* Function Name: CreateGrip * Description: Creates a grip widget. * Arguments: child - the child that wants a grip to be created for it. * Returns: none. */ static void CreateGrip(child) Widget child; { PanedWidget pw = (PanedWidget) XtParent(child); Arg arglist[2]; Cardinal num_args = 0; Cursor cursor; XtSetArg(arglist[num_args], XtNtranslations, pw->paned.grip_translations); num_args++; if ( (cursor = pw->paned.grip_cursor) == None ) if (IsVert(pw)) cursor = pw->paned.v_grip_cursor; else cursor = pw->paned.h_grip_cursor; XtSetArg(arglist[num_args], XtNcursor, cursor); num_args++; PaneInfo(child)->grip = XtCreateWidget("grip", gripWidgetClass, (Widget)pw, arglist, num_args); XtAddCallback(PaneInfo(child)->grip, XtNcallback, HandleGrip, (caddr_t) child); } /* Function Name: GetGCs * Description: Gets new GC's. * Arguments: w - the paned widget. * Returns: none. */ static void GetGCs(w) Widget w; { PanedWidget pw = (PanedWidget) w; XtGCMask valuemask; XGCValues values; /* * Draw pane borders in internal border color. */ values.foreground = pw->paned.internal_bp; valuemask = GCForeground; pw->paned.normgc = XtGetGC(w, valuemask, &values$O? XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2RnI); /* * Erase pane borders with background color. */ values.foreground = pw->core.background_pixel; valuemask = GCForeground; pw->paned.invgc = XtGetGC(w, valuemask, &values); /* * Draw Track lines (animate pane borders) in internal border color ^ bg color. */ values.function = GXinvert; values.plane_mask = pw->paned.internal_bp ^ pw->core.background_pixel; values.subwindow_mode = IncludeInferiors; valuemask = GCPlaneMask | GCFunction | GCSubwindowMode; pw->paned.flipgc = XtGetGC(w, valuemask, &values); } /* Function Name: SetChildrenPrefSizes. * Description: Sets the preferred sizes of the children. * Arguments: pw - the paned widget. * Returns: none. */ static void SetChildrenPrefSizes(pw, off_size) PanedWidget pw; Dimension off_size; { Widget * childP; Boolean vert = IsVert(pw); XtWidgetGeometry request, reply; ForAllPanes(pw, childP) if ( pw->paned.resize_children_to_pref || (PaneInfo(*childP)->size == 0) || (PaneInfo(*childP)->resize_to_pref) ) { if (PaneInfo(*childP)->preferred_size != PANED_ASK_CHILD) PaneInfo(*childP)->wp_size=PaneInfo(*childP)->preferred_size; else { if( vert ) { request.request_mode = CWWidth; request.width = off_size; } else { request.request_mode = CWHeight; request.height = off_size; } if ((XtQueryGeometry( *childP, &request, &reply ) == XtGeometryAlmost) && (reply.rl XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn-OLequest_mode = (vert ? CWHeight : CWWidth))) PaneInfo(*childP)->wp_size = GetRequestInfo(&reply, vert); else PaneInfo(*childP)->wp_size = PaneSize(*childP, vert); } PaneInfo(*childP)->size = PaneInfo(*childP)->wp_size; } } /* Function Name: ChangeAllGripCursors * Description: Changes all the grip cursors. * Arguments: pw - the paned widget. * Returns: none */ static void ChangeAllGripCursors(pw) PanedWidget pw; { Widget * childP; ForAllPanes(pw, childP) { Arg arglist[1]; Cursor cursor; if ( (cursor = pw->paned.grip_cursor) == None ) if ( IsVert(pw) ) cursor = pw->paned.v_grip_cursor; else cursor = pw->paned.h_grip_cursor; if (HasGrip (*childP)) { XtSetArg(arglist[0], XtNcursor, cursor); XtSetValues(PaneInfo(*childP)->grip, arglist, (Cardinal) 1); } } } /************************************************************ * * Stack Manipulation routines (Private). * ************************************************************/ /* Function Name: PushPaneStack * Description: Pushes a value onto the pane stack. * Arguments: pw - the paned widget. * pane - the pane that we are pushing. * Returns: none. */ static void PushPaneStack(pw, pane) PanedWidget pw; Pane pane; { PaneStack * stack = (PaneStack *) XtMalloc(sizeof(PaneStack)); stack->next = pw->paned.stack; stack->pane = pane; stack->start_size = pane->size; pw->paned.stack = stack; } /* Function Name: GetPaneStack * Descripti5J9 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2RnOon: Gets the top value from the pane stack. * Arguments: pw - the paned widget. * shrink - TRUE if we want to shrink this pane, * FALSE otherwise. * ** RETURNED ** pane - the pane that we are popping. * ** RETURNED ** start_size - the size that this pane started at. * Returns: none. */ static void GetPaneStack(pw, shrink, pane, start_size) PanedWidget pw; Boolean shrink; Pane * pane; int * start_size; { if (pw->paned.stack == NULL) { *pane = NULL; return; } *pane = pw->paned.stack->pane; *start_size = pw->paned.stack->start_size; if (shrink != ((*pane)->size > *start_size)) *pane = NULL; } /* Function Name: PopPaneStack * Description: Pops the top item off the pane stack. * Arguments: pw - the paned widget. * Returns: TRUE if this is not the last element on the stack. */ static Boolean PopPaneStack(pw) PanedWidget pw; { PaneStack * stack = pw->paned.stack; if (stack == NULL) return(FALSE); pw->paned.stack = stack->next; XtFree(stack); if (pw->paned.stack == NULL) return(FALSE); return(TRUE); } /* Function Name: ClearPaneStack * Description: removes all entries from the pane stack. * Arguments: pw - the paned widget. * Returns: none */ static void ClearPaneStack(pw) PanedWidget pw; { while(PopPaneStack(pw)); } /************************************************************ * * Semi-public routines. * ************************************************************/ /* Function Name: ClassInitialize * Descript|xp XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2RnVRion: The Paned widgets class initialization proc. * Arguments: none. * Returns: none. */ static void ClassInitialize() { XawInitializeWidgetSet(); XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation, NULL, (Cardinal)0 ); } /* The Geometry Manager only allows changes after Realize if * allow_resize is True in the constraints record. * * For vertically paned widgets: * * It only allows height changes, but offers the requested height * as a compromise if both width and height changes were requested. * * For horizontal widgets the coverse is true. * As all good Geometry Managers should, we will return No if the * request will have no effect; i.e. when the requestor is already * of the desired geometry. */ static XtGeometryResult GeometryManager(w, request, reply) Widget w; XtWidgetGeometry *request, *reply; { PanedWidget pw = (PanedWidget) XtParent(w); XtGeometryMask mask = request->request_mode; Dimension old_size, old_wpsize, old_paned_size; Pane pane = PaneInfo(w); register Boolean vert = IsVert(pw); Dimension on_size, off_size; XtGeometryResult result; Boolean almost = FALSE; /* * If any of the following is true, disallow the geometry change. * * o The paned widget is realized and allow_resize is false for the pane. * o The child did not ask to change the on_size. * o The request is not a width or height request. * o The requested size is the same as the current size. */ if ( (XtIsRealized((Widget)pw) && !pane->allۢ% XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn%Uow_resize) || !(mask & ((vert) ? CWHeight : CWWidth)) || (mask & ~(CWWidth | CWHeight)) || (GetRequestInfo(request, vert) == PaneSize(w, vert)) ) { return XtGeometryNo; } old_paned_size = PaneSize( (Widget) pw, vert); old_wpsize = pane->wp_size; old_size = pane->size; pane->wp_size = pane->size = GetRequestInfo(request, vert); AdjustPanedSize(pw, PaneSize((Widget) pw, !vert), &result, &on_size, &off_size); /* * Fool the Refigure Locations proc to thinking that we are * a different on_size; */ if (result != XtGeometryNo) if (vert) pw->core.height = on_size; else pw->core.width = on_size; RefigureLocations(pw, PaneIndex(w), AnyPane); /* * Set up reply struct and reset core on_size. */ if (vert) { pw->core.height = old_paned_size; reply->height = pane->size; reply->width = off_size; } else { pw->core.width = old_paned_size; reply->height = off_size; reply->width = pane->size; } /* * IF either of the following is true. * * o There was a "off_size" request and the new "off_size" is different * from that requested. * o There was no "off_size" request and the new "off_size" is different * * o The "on_size" we will allow is different from that requested. * * THEN: set almost */ if ( !((vert ? CWWidth : CWHeight) & mask)) if (vert) request->width = w->core.width; else request-?M XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn%X>height = w->core.height; almost = GetRequestInfo(request, !vert) != GetRequestInfo(reply, !vert); almost |= GetRequestInfo(request, vert) != GetRequestInfo(reply, vert); if ( (mask & XtCWQueryOnly) || almost ) { pane->wp_size = old_wpsize; pane->size = old_size; RefigureLocations(pw, PaneIndex(w), AnyPane); reply->request_mode = CWWidth | CWHeight; if (almost) return XtGeometryAlmost; } else { AdjustPanedSize(pw, PaneSize((Widget) pw, !vert), NULL, NULL, NULL); CommitNewLocations( pw ); /* layout already refigured. */ } return XtGeometryDone; } /* ARGSUSED */ static void Initialize(request, new) Widget request, new; { PanedWidget pw = (PanedWidget)new; GetGCs( (Widget) pw); pw->paned.recursively_called = False; pw->paned.stack = NULL; pw->paned.resize_children_to_pref = TRUE; pw->paned.num_panes = 0; } static void Realize(w, valueMask, attributes) Widget w; Mask *valueMask; XSetWindowAttributes *attributes; { PanedWidget pw = (PanedWidget) w; Widget * childP; if ((attributes->cursor = (pw)->paned.cursor) != None) *valueMask |= CWCursor; (*SuperClass->core_class.realize) (w, valueMask, attributes); /* * Before we commit the new locations we need to realize all the panes and * their grips. */ ForAllPanes(pw, childP) { XtRealizeWidget( *childP ); if (HasGrip (*childP)) XtRealizeWidget( PaneInfo(*childP)->grip ); } RefigureLocationsAndCommit(w); } /* Realize */ static void ReleaseGCs(w) WidSC XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rnn)[get w; { register PanedWidget pw = (PanedWidget)w; XtReleaseGC( w, pw->paned.normgc ); XtReleaseGC( w, pw->paned.invgc ); XtReleaseGC( w, pw->paned.flipgc ); } static void InsertChild(w, args, argcount) register Widget w; ArgList args; Cardinal *argcount; { Pane pane = PaneInfo(w); /* insert the child widget in the composite children list with the */ /* superclass insert_child routine. */ (*SuperClass->composite_class.insert_child)(w, args, argcount); if (!IsPane(w)) return; /* ||| Panes will be added in the order they are created, temporarilly */ if ( pane->show_grip == TRUE ) { CreateGrip(w); if (pane->min == PANED_GRIP_SIZE) pane->min = PaneSize(pane->grip, IsVert((PanedWidget) XtParent(w))); } else { if (pane->min == PANED_GRIP_SIZE) pane->min = 1; pane->grip = NULL; } pane->size = 0; pane->paned_adjusted_me = FALSE; } /* InsertChild */ static void DeleteChild(w) Widget w; { /* remove the subwidget info and destroy the grip */ if ( IsPane(w) && HasGrip(w) ) XtDestroyWidget(PaneInfo(w)->grip); /* delete the child widget in the composite children list with the */ /* superclass delete_child routine. */ (*SuperClass->composite_class.delete_child) (w); } /* DeleteChild */ static void ChangeManaged(w) Widget w; { PanedWidget pw = (PanedWidget)w; Boolean vert = IsVert(pw); Dimension size; register Widget *childP;  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn^ if (pw->paned.recursively_called++) return; /* * If the size is zero then set it to the size of the widest or tallest pane. */ if ( (size = PaneSize( (Widget) pw, !vert )) == 0) { size = 1; ForAllChildren(pw, childP) if ( XtIsManaged(*childP) && (PaneSize( *childP, !vert ) > size) ) size = PaneSize( *childP, !vert ); } ManageAndUnmanageGrips(pw); pw->paned.recursively_called = False; ResortChildren(pw); pw->paned.num_panes = 0; ForAllChildren(pw, childP) if ( IsPane(*childP) ) if ( XtIsManaged(*childP) ) { Pane pane = PaneInfo(*childP); if (HasGrip(*childP)) PaneInfo(pane->grip)->position = pw->paned.num_panes; pane->position = pw->paned.num_panes; /*TEMPORY -CDP 3/89 */ pw->paned.num_panes++; } else break; /* This list is already sorted. */ SetChildrenPrefSizes( (PanedWidget) w, size); /* * ForAllPanes can now be used. */ if ( PaneSize((Widget) pw, vert) == 0 ) AdjustPanedSize(pw, size, NULL, NULL, NULL); if (XtIsRealized( (Widget) pw)) RefigureLocationsAndCommit( (Widget) pw); } /* ChangeManaged */ /* Function Name: Resize * Description: The paned widget's resize proc. * Arguments: w - the paned widget. * Returns: none. */ static void Resize(w) Widget w; { SetChildrenPrefSizes( (PanedWidget) w, PaneSize(w, !IsVert((PanedWidget) w)) ); RefigureLocationsAndCommit(w); } /* ARGSUSED */ static void Redisplay(w, event, region) Widget w; XEvۙ>@e/8bbcX 0^J&;1 w2mqq(D^;+:NA:NbY'4VWt;ZORnwTR5hF .ee =?j;v7%!eLkNId\plX*H: N=mz3o8Ko6n#P|1{l~L 9OhV6[/k(jQ U&Y>G=fKNO?CoH.^bK'CcH L8)C+Z*u ('!$u@2:u^=n;@[km;T-X o>xc!#v]j Dkz|_6]O-AsDiJv .p@Xtm"sYAHX) (s1VQ7NCo82"bI?xH?~rK1qb/lvm?UJ`V[tb%VK_(36!x/ :tns<4`'8'TCmBlZ6XT?HkzDa!&SvRGOp5"gH=x&PKioL=kAU uWo vr aQ^1Z88Dx&3 fEI-\+ <m=P}]E"C|sK3YVWJU_-I M[+]27KcO7OT`PF Kv*EhP0]`{r5Fdxah`U49pCdI:htR7:^TWjPn&5b/ `ns _i/7}@wzW+N~ 4-5}Z=5NWbzgS,3KX`igTdffOBd RY |6R_F\hcYFh@Eh |Ju<$ciJyK.o )];7 )JJ ^d>zY{b: 5Q|Q0L7o* [:34G_ 8vya^=.G";*brpy"%ZY?*73219>0!6eEuGl@h~gOv4('pYMMHIQIW5zq7S[B*mo]M)0GrhG pO WPXl8l2):]U99eE6t [IQokoyQ:%RAz7Qy;S4]ZUP<_^Oc= Xe9E`kC$2Q]6Vvc'?]'_fa{G!Rc;h1Q hojo}| /o!/Q[X^]_qMM[yK8 m#TfL.p]FzC-&JHXbw&M+JI zAYh(_$*K$[5 ptjCrx`7Ivc?_Sf|d9e.M=Fp -PBS}Pbf62`gYn 83i#Jz?`b%Brv/K (67"JcB7pVik0.KWqS UIOu.Fl L)e0x@| %u5(.HHr0Pb> xv_D! 9:>b0 O G`@]e A> XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rnaent * event; /* unused. */ Region region; /* unused. */ { ((PanedWidget) w)->paned.resize_children_to_pref = FALSE; DrawInternalBorders( (PanedWidget) w); } /* ARGSUSED */ static Boolean SetValues(old, request, new) Widget old, request, new; { PanedWidget old_pw = (PanedWidget) old; PanedWidget new_pw = (PanedWidget) new; Boolean redisplay = FALSE; if ( (old_pw->paned.cursor != new_pw->paned.cursor) && XtIsRealized(new)) XDefineCursor(XtDisplay(new), XtWindow(new), new_pw->paned.cursor); if ( (old_pw->paned.internal_bp != new_pw->paned.internal_bp) || (old_pw->core.background_pixel != new_pw->core.background_pixel) ) { ReleaseGCs(old); GetGCs(new); redisplay = TRUE; } if ( (old_pw->paned.grip_cursor != new_pw->paned.grip_cursor) || (old_pw->paned.v_grip_cursor != new_pw->paned.v_grip_cursor) || (old_pw->paned.h_grip_cursor != new_pw->paned.h_grip_cursor) ) { ChangeAllGripCursors(new_pw); } if ( IsVert(old_pw) != IsVert(new_pw)) { /* * We are fooling the paned widget into thinking that is needs to * fully refigure everything, which is what we want. */ if (IsVert(new_pw)) new_pw->core.width = 0; else new_pw->core.height = 0; new_pw->paned.resize_children_to_pref = TRUE; ChangeManaged(new); /* Seems weird, but does the right thing. */ new_pw->paned.resize_children_to_pref = FALSE; if (new_pw->paned.grip_cursor == None) ChangeAllGripCursors(new_pw); return(TRUE); } if (old_pw XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;2Rn6d->paned.internal_bw != new_pw->paned.internal_bw) { AdjustPanedSize( new_pw, PaneSize(new, !IsVert(old_pw)), NULL, NULL, NULL); RefigureLocationsAndCommit(new); return(TRUE); /* We have done a full configuration, return.*/ } if ( (old_pw->paned.grip_indent != new_pw->paned.grip_indent) && (XtIsRealized(new)) ) { CommitNewLocations(new_pw); redisplay = TRUE; } return (redisplay); } /* SetValues */ /* ARGSUSED */ static Boolean PaneSetValues(old, request, new) Widget old, request, new; { Pane old_pane = PaneInfo(old); Pane new_pane = PaneInfo(new); Boolean redisplay = FALSE; /* Check for new min and max. */ if (old_pane->min != new_pane->min || old_pane->max != new_pane->max) XawPanedSetMinMax(new, (int)new_pane->min, (int)new_pane->max); /* Check for change in XtNshowGrip. */ if (old_pane->show_grip != new_pane->show_grip) if (new_pane->show_grip == TRUE) { CreateGrip(new); if (XtIsRealized(XtParent(new))) { if (XtIsManaged(new)) /* if paned is unrealized this will happen automatically at realize time.*/ XtManageChild(PaneInfo(new)->grip); /* manage the grip. */ XtRealizeWidget(PaneInfo(new)->grip); /* realize the grip. */ CommitNewLocations( (PanedWidget) XtParent(new) ); } } else if ( HasGrip(old) ) { XtDestroyWidget( old_pane->grip ); new_pane->grip = NULL; redisplay = TRUE; } /* ||| need to look at position changes */ return(redisplayI'5 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;22Rng); } /************************************************************ * * Public routines. * ************************************************************/ /* Function Name: XawPanedSetMinMax * Description: Sets the min and max size for a pane. * Arguments: widget - the widget that is a child of the Paned widget. * min, max - the new min and max size for the pane. * Returns: none. */ void XawPanedSetMinMax(widget, min, max) Widget widget; int min, max; { Pane pane = PaneInfo(widget); pane->min = min; pane->max = max; RefigureLocationsAndCommit( widget->core.parent ); } /* Function Name: XawPanedGetMinMax * Description: Gets the min and max size for a pane. * Arguments: widget - the widget that is a child of the Paned widget. ** RETURNED ** min, max - the current min and max size for the pane. * Returns: none. */ void XawPanedGetMinMax(widget, min, max) Widget widget; int *min, *max; { Pane pane = PaneInfo(widget); *min = pane->min; *max = pane->max; } /* Function Name: XawPanedSetRefigureMode * Description: Allows a flag to be set the will inhibit * the paned widgets relayout routine. * Arguments: w - the paned widget. * mode - if FALSE then inhibit refigure. * Returns: none. */ void XawPanedSetRefigureMode(w, mode) Widget w; Boolean mode; { ((PanedWidget) w)->paned.refiguremode = mode; RefigureLocationsAndCommit( w ); } /* Function Name: XawPanedGetNumSub * Description: Returns the numberX XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]PANED.C;22Rn^ j of panes in the paned widget. * Arguments: w - the paned widget. * Returns: the number of panes in the paned widget. */ int XawPanedGetNumSub(w) Widget w; { return ((PanedWidget)w)->paned.num_panes; } /* Function Name: XawPanedAllowResize * Description: Allows a flag to be set that determines if the paned * widget will allow geometry requests from this child * Arguments: widget - a child of the paned widget. * Returns: none. */ void XawPanedAllowResize(widget, allow_resize) Widget widget; Boolean allow_resize; { PaneInfo(widget)->allow_resize = allow_resize; } *[MAHAN.XTERM.LIB.XAW]PANED.H;2+,r ./@ 4NY08 F-zr0123KPWO5608 F7 F8td9G@HJĐ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]PANED.H;22NY/* * $XConsortium: Paned.h,v 1.8 89/10/04 19:35:43 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. ******************************************************************/ /* * Paned.h - Paned Composite Widget's public header file. * * Updated and significantly modifided from the Athena VPaned Widget. * * Date: March 1, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit֐ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]PANED.H;2;9NV5@expo.lcs.mit.edu */ #ifndef _XawPaned_h #define _XawPaned_h #ifdef vax11c #include #else #include #endif /* vax11c */ /**************************************************************** * * Vertical Paned Widget (SubClass of CompositeClass) * ****************************************************************/ /* RESOURCES: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground betweenCursor Cursor Cursor ** border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 cursor Cursor Cursor None destroyCallback Callback Pointer NULL height Height Dimension 0 gripIndent GripIndent Position 16 gripCursor Cursor Cursor ** horizontalGripCursol Cursor Cursor sb_h_double_arrow horizontalBetweencursor Cursor Cursor sb_up_arrow internalBorderColor BorderColor Pixel XtDefaultForeground internalBorderWidth BorderWidth Position 1 leftCursor Cursor Cursor sb_left_arrow lowerCursor Cursor Cursor sb_down_arrow mappedWhenManaged MappedWhenManaged Boolean True orientation Orientation XtOrientation XtorientVertical refigureMode ) XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]PANED.H;2;9Nˬ Boolean Boolean On rightCursor Cursor Cursor sb_right_arrow sensitive Sensitive Boolean True upperCursor Cursor Cursor sb_up_arrow verticalBetweenCursor Cursor Cursor sb_left_arrow verticalGripCursor Cursor Cursor sb_v_double_arrow width Width Dimension 0 x Position Position 0 y Position Position 0 ** These resources now are set to the vertical or horizontal cursor depending upon orientation, by default. If a value is specified here then that cursor will be used reguardless of orientation. CONSTRAINT RESOURCES: Name Class RepType Default Value ---- ----- ------- ------------- allowResize Boolean Boolean False max Max Dimension unlimited min Min Dimension Grip Size preferredPaneSize PerferredPaneSize Dimension PANED_ASK_CHILD resizeToPreferred Boolean Boolean False showGrip ShowGrip Boolean True skipAdjust Boolean Boolean False */ #define PANED_ASK_CHILD 0 #define PANED_GRIP_SIZE 0 /* New Fields */ #define XtNallowResize "allowResize" #define XtNbetweenCursor "betweenCursor" #define XtNverticalBetweenCursor "verticalBetweenCursor" #define XtNhorizontalBetweenCursor "horizontalBetweenCursor" #define XtNgripCursor "gripCursor" #define XtNgripIndent "gripIndent" #define XtNhorizontalGripCursor "`o XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]PANED.H;2;9NoF horizontalGripCursor" #define XtNinternalBorderColor "internalBorderColor" #define XtNinternalBorderWidth "internalBorderWidth" #define XtNleftCursor "leftCursor" #define XtNlowerCursor "lowerCursor" #define XtNrefigureMode "refigureMode" #define XtNposition "position" #define XtNmin "min" #define XtNmax "max" #define XtNpreferredPaneSize "preferredPaneSize" #define XtNresizeToPreferred "resizeToPreferred" #define XtNrightCursor "rightCursor" #define XtNshowGrip "showGrip" #define XtNskipAdjust "skipAdjust" #define XtNupperCursor "upperCursor" #define XtNverticalGripCursor "verticalGripCursor" #define XtCGripIndent "GripIndent" #define XtCMin "Min" #define XtCMax "Max" #define XtCPreferredPaneSize "PreferredPaneSize" #define XtCShowGrip "ShowGrip" /* Class record constant */ #ifndef XAW_PANED_WIDGET #ifdef vax11c globalref WidgetClass panedWidgetClass; #else extern WidgetClass panedWidgetClass; #endif /* vax11c */ #endif /* !XAW_PANED_WIDGET */ #ifdef XAW_BC /* for compatability only. */ #ifdef vax11c globalref WidgetClass vPanedWidgetClass; #else extern WidgetClass vPanedWidgetClass; #endif /* vax11c */ #endif typedef struct _PanedClassRec *PanedWidgetClass; typedef struct _PanedRec *PanedWidget; /************************************************************ * * Public Procedures * ************************************************************/ /* Function Name: XawPanedSetMinMax * Description: Sets the min and max size for a pane. * Arguments: widget - the widget that is a child of the Pa!+ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]PANED.H;2;9N ned widget. * min, max - the new min and max size for the pane. * Returns: none. */ extern void XawPanedSetMinMax(); /* widget, min, max */ /* Widget widget; */ /* int min, max; */ /* Function Name: XawPanedGetMinMax * Description: Gets the min and max size for a pane. * Arguments: widget - the widget that is a child of the Paned widget. ** RETURNED ** min, max - the current min and max size for the pane. * Returns: none. */ extern void XawPanedGetMinMax(); /* widget, min, max */ /* Widget widget; */ /* int *min, *max; */ /* Function Name: XawPanedSetRefigureMode * Description: Allows a flag to be set the will inhibit * the paned widgets relayout routine. * Arguments: w - the paned widget. * mode - if FALSE then inhibit refigure. * Returns: none. */ extern void XawPanedSetRefigureMode(); /* w, mode */ /* Widget w; */ /* Boolean mode; */ /* Function Name: XawPanedGetNumSub * Description: Returns the number of panes in the paned widget. * Arguments: w - the paned widget. * Returns: the number of panes in the paned widget. */ extern int XawPanedGetNumSub(); /* w */ /* Widget w; */ /* Function Name: XawPanedAllowResize * Description: Allows a flag to be set that determines if the paned * widget will allow geometry requests from this child * Arguments: widget - a child of the paned widget. * Returns: none. */ extern void XawPanedAllowResize(); /* widget, allow_resize */ /* Wido XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]PANED.H;2;9N_get widget; */ /* Boolean allow_resize; */ #ifdef XAW_BC /************************************************************* * For Compatibility only. */ #define XtPanedSetMinMax XawPanedSetMinMax #define XtPanedGetMinMax XawPanedGetMinMax #define XtPanedGetNumSub XawPanedGetNumSub #define XtPanedAllowResize XawPanedAllowResize #define XtPanedSetRefigureMode XawPanedSetRefigureMode /*************************************************************/ #endif /* XAW_BC */ #endif /* _XawPaned_h */ /* DON'T ADD STUFF AFTER THIS #endif */ *[MAHAN.XTERM.LIB.XAW]PANEDP.H;2+,r ./@ 4OP F-zr0123KPWO56P F7p F8d9G@HJO 9oXI$u/MGaM46o*z4JhhEvb#L}Rtsx]qx:"BX[th: ZV&8^3]|}kZ4ZG|XGW}JT.[lGg0RAM6CRzTFi&G/e=N @1]mFW.t]%,sa0$4u9/: m USwC[xgC6n>\w68P: @=T j\T\kEs^TIM1} nq.f+ysQ_\8 KN'js1y8 ?fNrU5En:y?s{7e3Mi#_lS pc=Z_hMV@UL~:ti&7ma}4E G, e[QaW*~YPtGE&s d/nV4g'> U&t n`[3 S  wY WUW0][_8J$aC7 ]^%?-u>V:#}Y] !;sPf=mT 'aRudur I*B<>@=d6eHxK//.r$vzMa-J5FEb{FrRpG]DkR &W]<^1;aOZlTbVe5K{4:j{7 u, TJ6hWqL>x/2H06d u(;B&vLX}W 4"|^ZEkUQ0@H% s95<WOOwB]gKUvJ7#YD!Br72O[uO]_KUU8A ekg`O@wgehW5"]e hk)1BaE}=C 1MMqD#ur/nu- u 5 &QByZ9`v\nS~0bguA3 kEzLH633ST L'<}ST{ nTDu6ZRSYboTUBVzEvHd&!4?)q IgRn#]KO|2(s.#2V\+ Rxx6 =0FgKT<,^-i5r 9j0mdEuhOx}pv;><z{G\q~,;a:,8 (nDrlbH.Bb}g )*1D!^y(!EHN pLEx $|h?[jF[zs.(yf 8jEk8Ls0Uz)wRg).LeP<'r%Up87Yg1nI;.i~5?*p!N=-PHtH-k-d(7d q@G"2w*.}i. y'=}2/L[M]^kXwgwV1_grj*S };2Rus^6 1P*s?&'.1Ap[Ɲ鞹/(I)qtEFtw]R/vR!{r$*Ia;e'E}!(jVl auB"H8Z _K4{AQ#iVN=˚^֠UYB7Ğ``RHPpe^zV}OhS5oLtrzZ\;xGHM  :B29)- vF;qV  ;XLKP=q4;8h d%. q"&2ZeGC]6'*W%? M8vM{LSijP)|FL7y1N- J-|WT!BAw71 a\h[S$ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]PANEDP.H;29Ow/*********************************************************** $XConsortium: PanedP.h,v 1.4 89/05/11 01:06:12 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. ******************************************************************/ /* * PanedP.h - Paned Composite Widget's private header file. * * Updated and significantly modifided from the Athena VPaned Widget. * * Date: March 1, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@ex XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]PANEDP.H;29Opo.lcs.mit.edu */ #ifndef _XawPanedP_h #define _XawPanedP_h #ifdef vax11c #include "Paned.h" #include #else #include #include #endif /* vax11c */ /********************************************************************* * * Paned Widget Private Data * *********************************************************************/ /* New fields for the Paned widget class record */ typedef struct _PanedClassPart { int foo; /* keep compiler happy. */ } PanedClassPart; /* Full Class record declaration */ typedef struct _PanedClassRec { CoreClassPart core_class; CompositeClassPart composite_class; ConstraintClassPart constraint_class; PanedClassPart paned_class; } PanedClassRec; #ifndef XAW_PANED_WIDGET #ifdef vax11c globalref PanedClassRec panedClassRec; #else extern PanedClassRec panedClassRec; #endif /* vax11c */ #endif /* !XAW_PANED_WIDGET */ /* Paned constraint record */ typedef struct _PanedConstraintsPart { /* Resources. */ Dimension min; /* Minimum height */ Dimension max; /* Maximum height */ Boolean allow_resize; /* TRUE iff child resize requests are ok */ Boolean show_grip; /* TRUE iff child will have grip below it, when it is not the bottom pane. */ Boolean skip_adjust; /* TRUE iff child's height should not be */ /* changed without explicit user action. */ int position; /* position location in Paned (relative to other children) ** NIY ** */ Dimension  XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]PANEDP.H;29O preferred_size; /* The Preferred size of the pane. Iff this is zero then ask child for size.*/ Boolean resize_to_pref; /* resize this pane to its preferred size on a resize or change managed after realize. */ /* Private state. */ Position delta; /* Desired Location */ Position olddelta; /* The last value of dy. */ Boolean paned_adjusted_me; /* Has the vpaned adjusted this widget w/o user interaction to make things fit? */ Dimension wp_size; /* widget's preferred size */ int size; /* the size the widget will actually get. */ Widget grip; /* The grip for this child */ } PanedConstraintsPart, *Pane; typedef struct _PanedConstraintsRec { PanedConstraintsPart paned; } PanedConstraintsRec, *PanedConstraints; /* * The Pane Stack Structure. */ typedef struct _PaneStack { struct _PaneStack * next; /* The next element on the stack. */ Pane pane; /* The pane in thise element on the stack. */ int start_size; /* The size of this element when it was pushed onto the stack. */ } PaneStack; /* New Fields for the Paned widget record */ typedef struct { /* resources */ Position grip_indent; /* Location of grips (offset from right margin) */ Boolean refiguremode; /* Whether to refigure changes right now */ XtTranslations grip_translations; /* grip translation table */ Pixel internal_bp; /* color of internal bordersOj XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]PANEDP.H;29O[{ . */ Dimension internal_bw; /* internal border width. */ XtOrientation orientation; /* Orientation of paned widget. */ Cursor cursor; /* Cursor for paned window */ Cursor grip_cursor; /* inactive grip cursor */ Cursor v_grip_cursor; /* inactive vert grip cursor */ Cursor h_grip_cursor; /* inactive horiz grip cursor */ Cursor adjust_this_cursor; /* active grip cursor: T */ Cursor v_adjust_this_cursor; /* active vert grip cursor: T */ Cursor h_adjust_this_cursor; /* active horiz grip cursor: T */ /* vertical. */ Cursor adjust_upper_cursor; /* active grip cursor: U */ Cursor adjust_lower_cursor; /* active grip cursor: D */ /* horizontal. */ Cursor adjust_left_cursor; /* active grip cursor: U */ Cursor adjust_right_cursor; /* active grip cursor: D */ /* private */ Boolean recursively_called; /* for ChangeManaged */ Boolean resize_children_to_pref; /* override constrain resources and resize all children to preferred size. */ int start_loc; /* mouse origin when adjusting */ Widget whichadd; /* Which pane to add changes to */ Widget whichsub; /* Which pane to sub changes from */ GC normgc; /* GC to use when drawing borders */ GC invgc; /* GC to u9 XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]PANEDP.H;29O se when erasing borders */ GC flipgc; /* GC to use when animating borders */ int num_panes; /* count of managed panes */ PaneStack * stack; /* The pane stack for this widget.*/ } PanedPart; /************************************************************************** * * Full instance record declaration * **************************************************************************/ typedef struct _PanedRec { CorePart core; CompositePart composite; ConstraintPart constraint; PanedPart paned; } PanedRec; #endif /* _XawPanedP_h */ /* DON'T ADD STUFF AFTER THIS #endif */ *[MAHAN.XTERM.LIB.XAW]SCROLL.H;1+,r./@ 40] F-zr0123KPWO560] F7Y F8>d9G@HJ. XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SCROLL.H;19;/* This file is made obsolete by Scrollbar.h */ /* * Only allow the use of the old name when the back compatability * flag is set. * * Chris Peterson - 12/15/89 */ #ifdef XAW_BC # include #endif "*[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2+,r .-/@ 4O-* !F-zr0123KPWO+56!F7/!F8pNne9G@HJ#ifndef lint static char Xrcsid[] = "$XConsortium: Scrollbar.c,v 1.58 89/12/15 11:36:58 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 gra4 XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O-nted, 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. ******************************************************************/ /* ScrollBar.c */ /* created by weissman, Mon Jul 7 13:20:03 1986 */ /* converted by swick, Thu Aug 27 1987 */ /* ported to vms by mahan, Wed Oct 30 1991 */ #define XAW_SCROLLBAR_WIDGET #ifdef vax11c #include #include #include "XawInit.h" #include "ScrollbarP.h" #else #include #include #include #include #endif /* vax11c */ /* Private definitions. */ static char defaultTranslations[] = ": StartScroll(Forward) \n\ : StartScroll(Continuous) MoveThumb() NotifyThumb() \n\ : StartScroll(Backward) \n\  XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O-iw : MoveThumb() NotifyThumb() \n\ : NotifyScroll(Proportional) EndScroll()"; #ifdef bogusScrollKeys /* examples */ "f: StartScroll(Forward) NotifyScroll(FullLength) EndScroll()" "b: StartScroll(Backward) NotifyScroll(FullLength) EndScroll()" #endif static float floatZero = 0.0; #define Offset(field) XtOffset(ScrollbarWidget, field) static XtResource resources[] = { {XtNlength, XtCLength, XtRDimension, sizeof(Dimension), Offset(scrollbar.length), XtRImmediate, (caddr_t) 1}, {XtNthickness, XtCThickness, XtRDimension, sizeof(Dimension), Offset(scrollbar.thickness), XtRImmediate, (caddr_t) 14}, {XtNorientation, XtCOrientation, XtROrientation, sizeof(XtOrientation), Offset(scrollbar.orientation), XtRImmediate, (caddr_t) XtorientVertical}, {XtNscrollProc, XtCCallback, XtRCallback, sizeof(caddr_t), Offset(scrollbar.scrollProc), XtRCallback, NULL}, {XtNthumbProc, XtCCallback, XtRCallback, sizeof(caddr_t), Offset(scrollbar.thumbProc), XtRCallback, NULL}, {XtNjumpProc, XtCCallback, XtRCallback, sizeof(caddr_t), Offset(scrollbar.jumpProc), XtRCallback, NULL}, {XtNthumb, XtCThumb, XtRPixmap, sizeof(Pixmap), Offset(scrollbar.thumb), XtRImmediate, (XtPointer) XtUnspecifiedPixmap}, {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), Offset(scrollbar.foreground), XtRString, XtDefaultForeground}, {XtNshown, XtCShown, XtRFloat, sizeof(float), Offset(scrollbar.shown), XtRFloat, (7ti XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O-͝caddr_t)&floatZero}, {XtNtopOfThumb, XtCTopOfThumb, XtRFloat, sizeof(float), Offset(scrollbar.top), XtRFloat, (caddr_t)&floatZero}, {XtNscrollVCursor, XtCCursor, XtRCursor, sizeof(Cursor), Offset(scrollbar.verCursor), XtRString, "sb_v_double_arrow"}, {XtNscrollHCursor, XtCCursor, XtRCursor, sizeof(Cursor), Offset(scrollbar.horCursor), XtRString, "sb_h_double_arrow"}, {XtNscrollUCursor, XtCCursor, XtRCursor, sizeof(Cursor), Offset(scrollbar.upCursor), XtRString, "sb_up_arrow"}, {XtNscrollDCursor, XtCCursor, XtRCursor, sizeof(Cursor), Offset(scrollbar.downCursor), XtRString, "sb_down_arrow"}, {XtNscrollLCursor, XtCCursor, XtRCursor, sizeof(Cursor), Offset(scrollbar.leftCursor), XtRString, "sb_left_arrow"}, {XtNscrollRCursor, XtCCursor, XtRCursor, sizeof(Cursor), Offset(scrollbar.rightCursor), XtRString, "sb_right_arrow"}, {XtNminimumThumb, XtCMinimumThumb, XtRDimension, sizeof(Dimension), Offset(scrollbar.min_thumb), XtRImmediate, (caddr_t) 7}, }; static void ClassInitialize(); static void Initialize(); static void Destroy(); static void Realize(); static void Resize(); static void Redisplay(); static Boolean SetValues(); static void StartScroll(); static void MoveThumb(); static void NotifyThumb(); static void NotifyScroll(); static void EndScroll(); static XtActionsRec actions[] = { {"StartScroll", StartScroll}, {"MoveThumb", MoveThumb}, {"NotifyThumb", NotifyThumb}, {"NotifyScroll", NotifyScroll}, {"EndScroll", EndScroll}, {NU XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O-P LL,NULL} }; #ifdef vax11c globaldef {"scrollbarclassrec"} noshare #endif vax11c ScrollbarClassRec scrollbarClassRec = { /* core fields */ /* superclass */ (WidgetClass) &widgetClassRec, /* class_name */ "Scrollbar", /* size */ sizeof(ScrollbarRec), /* class_initialize */ ClassInitialize, /* class_part_init */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ Realize, /* actions */ actions, /* num_actions */ XtNumber(actions), /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* 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 */ defaultTranslations, /* query_geometry */ XtInheritQueryGeometry, /* display_accelerator*/ XtInheritDisplayAccelerator, /* extension */ NULL }; #ifdef vax11c globaldef {"scrollbarwidgetclass"} noshME O QlsSVb_~]Jw.@ [MO8&.7t q8YgNH :NhX{\R2$k90z?8Qpm$p,} Z(\`(0pO:f.wMkBna.E8uT9N[MbDiITYuWjb Y1YrWjj^&>MO EfEfarqA#cKX%]y,1)gmMy1Tdf16t4se/5e*O {u0\J $ !VHpQm -1\tpX#Oq?sB;st,vK&f d[^Cvwp7fz|t>33JWxHC?q' X_cLDo8I#.3jOrhK~h?BKu&0[A{9p=fq2,6}aZ Z~p\tB4CIj-4x.6|Z:|uR #m3Y< Wl`7HQ|YaVrTel8UqlMrD$-2Su$ _<3 uDx@N &|~sbJMyWF iD90_sS9  i_p>)q$i eBk#YE[|z[c18|N_yB[1J0Z/TE>Icx)kp8Az3 ~.a"'%Ke*KqvAhS(H5'qP8~=aHI? v~PVA`[Fs~B @0oAqd^OwVHy0]WpL;op2MSO8<'UGz}"Mtt1th=haN,YbrV8#WQ!vavP^%s '>?C"W4H MMIhB4zES 4|_#+* ?uxF<#hskqv9m_9Ak)K()y$VduB 's4!~w -`/#C6T9XG$5N{}A Ql_- vlKl(M7B CoiXl|u;pX&8zh{c\P>eG%4Rg]ieVwi-q~ ~v"NRhU>sy4%5k ,r2g7Jdx8Uw<SP7Wu^<@ aAl8B=vJOVLgcFIzx %5YPQ[I3\7! t x0[ 2)u(|d*JFAS' K1eMHW09*yAC,(e\v(Ag3FHTaY$3@_4OexCQ\wpC) !c&0ov~=IUCl5Y@?a(VOU(o :9r\u{ BLK'EG\g^ ~FXI dNMg3~nDOxrpdMX-scrollbar.orientation == XtorientHorizontal) ? x : y) #define MIN(x,y) ((x) < (y) ? (x) : (y)) #define MAX(x,y) ((x) > (y) ? (x) : (y)) static void ClassInitialize() { static XtConvertArgRec screenConvertArg[] = { {XtWidgetBaseOffset, (caddr_t) XtOffset(Widget, core.screen), sizeof(Screen *)} }; XawInitializeWidgetSet(); XtAddConverter( XtRString, XtROrientation, XmuCvtStringToOrientation, NULL, (Cardinal)0 ); XtAddConverter( XtRString, XtRPixmap, XmuCvtStringToBitmap, screenConvertArg, XtNumber(screenConvertArg)); } /* * Make sure the first number is within the range specified by the other * two numbers. */ static int InRange(num, small, big) int num, small, big; { return (num < small) ? small : ((num > big) ? big : num); } /* * Same as above, but for floating numbers. */ static float FloatInRange(num, small, big) float num, small, big; { return (num < small) ? small : ((num > big) ? big : num); } /* Fill the area specified by top and bottom with the given pattern. */ static float FractionLoc(w, x, y) ScrollbarWidget w; int x, y; { float result; result = PICKLENGTH(w, (float) x/w->core.width, (float) y/w->core.height); return FloatInRange(result, 0.0, 1.0); } static FillArea(w, top, bottom, thumb) ScrollbarWidget w; Position top, bottom; int thumb; { D8 XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O-{imension length = bottom-top; if (bottom < 0) return; switch(thumb) { /* Fill the new Thumb location */ case 1: if (w->scrollbar.orientation == XtorientHorizontal) XFillRectangle(XtDisplay(w), XtWindow(w), w->scrollbar.gc, top, 1, length, w->core.height-2); else XFillRectangle(XtDisplay(w), XtWindow(w), w->scrollbar.gc, 1, top, w->core.width-2, length); break; /* Clear the old Thumb location */ case 0: if (w->scrollbar.orientation == XtorientHorizontal) XClearArea(XtDisplay(w), XtWindow(w), top, 1, length, w->core.height-2, FALSE); else XClearArea(XtDisplay(w), XtWindow(w), 1, top, w->core.width-2, length, FALSE); } } /* Paint the thumb in the area specified by w->top and w->shown. The old area is erased. The painting and erasing is done cleverly so that no flickering will occur. */ static void PaintThumb( w ) ScrollbarWidget w; { Position oldtop, oldbot, newtop, newbot; oldtop = w->scrollbar.topLoc; oldbot = oldtop + w->scrollbar.shownLength; newtop = w->scrollbar.length * w->scrollbar.top; newbot = newtop + (int)(w->scrollbar.length * w->scrollbar.shown); if (newbot < newtop + w->scrollbar.min_thumb) newbot = newtop + w->scrollbar.min_thumb; w->scrollbar.topLoc = newtop; w->scrollbar.shownLength = newbot - newtop; if (XtIsRealized((Widget)w)) { if (newtop < oldtop) FillArea(w, newtop, MIN(newbot, oldtop), 1); if (newtop > oldtop) FillArea(w, oldtop, MIN(newtop, oldbot4b% XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O-"), 0); if (newbot < oldbot) FillArea(w, MAX(newbot, oldtop), oldbot, 0); if (newbot > oldbot) FillArea(w, MAX(newtop, oldbot), newbot, 1); } } static void SetDimensions(w) ScrollbarWidget w; { if (w->scrollbar.orientation == XtorientVertical) { w->scrollbar.length = w->core.height; w->scrollbar.thickness = w->core.width; } else { w->scrollbar.length = w->core.width; w->scrollbar.thickness = w->core.height; } } /* Function Name: Destroy * Description: Called as the scrollbar is going away... * Arguments: w - the scrollbar. * Returns: nonw */ static void Destroy(w) Widget w; { ScrollbarWidget sbw = (ScrollbarWidget) w; XtReleaseGC(w, sbw->scrollbar.gc); } /* Function Name: CreateGC * Description: Creates the GC. * Arguments: w - the scrollbar widget. * Returns: none. */ static void CreateGC(w) Widget w; { ScrollbarWidget sbw = (ScrollbarWidget) w; XGCValues gcValues; XtGCMask mask; unsigned int depth = 1; if (sbw->scrollbar.thumb == XtUnspecifiedPixmap) { sbw->scrollbar.thumb = XmuCreateStippledPixmap (XtScreen(w), (Pixel) 1, (Pixel) 0, depth); } else if (sbw->scrollbar.thumb != None) { Window root; int x, y; unsigned int width, height, bw; if (XGetGeometry(XtDisplay(w), sbw->scrollbar.thumb, &root, &x, &y, &width, &height, &bw, &depth) == 0) { XtAppError(XtWidgetToApplicationContext(w), "Scrollbar Widget: Could not get geometry of thumb pixmap."); } } gcValues.foreground =   XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O-bsbw->scrollbar.foreground; gcValues.background = sbw->core.background_pixel; mask = GCForeground | GCBackground; if (sbw->scrollbar.thumb != None) { if (depth == 1) { gcValues.fill_style = FillOpaqueStippled; gcValues.stipple = sbw->scrollbar.thumb; mask |= GCFillStyle | GCStipple; } else { gcValues.fill_style = FillTiled; gcValues.tile = sbw->scrollbar.thumb; mask |= GCFillStyle | GCTile; } } sbw->scrollbar.gc = XtGetGC( w, mask, &gcValues); } /* ARGSUSED */ static void Initialize( request, new ) Widget request; /* what the client asked for */ Widget new; /* what we're going to give him */ { ScrollbarWidget w = (ScrollbarWidget) new; CreateGC(new); if (w->core.width == 0) w->core.width = (w->scrollbar.orientation == XtorientVertical) ? w->scrollbar.thickness : w->scrollbar.length; if (w->core.height == 0) w->core.height = (w->scrollbar.orientation == XtorientHorizontal) ? w->scrollbar.thickness : w->scrollbar.length; SetDimensions( w ); w->scrollbar.direction = 0; w->scrollbar.topLoc = 0; w->scrollbar.shownLength = w->scrollbar.min_thumb; } static void Realize( gw, valueMask, attributes ) Widget gw; Mask *valueMask; XSetWindowAttributes *attributes; { ScrollbarWidget w = (ScrollbarWidget) gw; w->scrollbar.inactiveCursor = (w->scrollbar.orientation == XtorientVertical) ? w->scrollbar.verCursor : w->scrollbar.horCursor; attributes->cursor = w->scrollbar.inactiveCursor;  XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O- *valueMask |= CWCursor; XtCreateWindow( gw, InputOutput, (Visual *)CopyFromParent, *valueMask, attributes ); } /* ARGSUSED */ static Boolean SetValues( current, request, desired ) Widget current, /* what I am */ request, /* what he wants me to be */ desired; /* what I will become */ { ScrollbarWidget w = (ScrollbarWidget) current; ScrollbarWidget dw = (ScrollbarWidget) desired; Boolean redraw = FALSE; /* * If these values are outside the acceptable range ignore them... */ if (dw->scrollbar.top < 0.0 || dw->scrollbar.top > 1.0) dw->scrollbar.top = w->scrollbar.top; if (dw->scrollbar.shown < 0.0 || dw->scrollbar.shown > 1.0) dw->scrollbar.shown = w->scrollbar.shown; /* * Change colors and stuff... */ if ( XtIsRealized (desired) ) { if ( (w->scrollbar.foreground != dw->scrollbar.foreground) || (w->core.background_pixel != dw->core.background_pixel) || (w->scrollbar.thumb != dw->scrollbar.thumb) ) { XtReleaseGC(w, w->scrollbar.thumb); CreateGC( (Widget) dw); redraw = TRUE; } if (w->scrollbar.top != dw->scrollbar.top || w->scrollbar.shown != dw->scrollbar.shown) redraw = TRUE; } return( redraw ); } static void Resize( gw ) Widget gw; { /* ForgetGravity has taken care of background, but thumb may * have to move as a result of the new size. */ SetDimensions( (ScrollbarWidget)gw ); Redisplay( gw, (XEvent*)NULL, (Region)NULL ); } /* ARGSUSED */ static void RedisplC  XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O-*ay( gw, event, region ) Widget gw; XEvent *event; Region region; { ScrollbarWidget w = (ScrollbarWidget) gw; int x, y; unsigned int width, height; if (w->scrollbar.orientation == XtorientHorizontal) { x = w->scrollbar.topLoc; y = 1; width = w->scrollbar.shownLength; height = w->core.height - 2; } else { x = 1; y = w->scrollbar.topLoc; width = w->core.width - 2; height = w->scrollbar.shownLength; } if ( (region == NULL) || (XRectInRegion(region, x, y, width, height) != RectangleOut) ) { /* Forces entire thumb to be painted. */ w->scrollbar.topLoc = -(w->scrollbar.length + 1); PaintThumb( w ); } } /* ARGSUSED */ static void StartScroll( gw, event, params, num_params ) Widget gw; XEvent *event; String *params; /* direction: Back|Forward|Smooth */ Cardinal *num_params; /* we only support 1 */ { ScrollbarWidget w = (ScrollbarWidget) gw; Cursor cursor; char direction; if (w->scrollbar.direction != 0) return; /* if we're already scrolling */ if (*num_params > 0) direction = *params[0]; else direction = 'C'; w->scrollbar.direction = direction; switch( direction ) { case 'B': case 'b': cursor = (w->scrollbar.orientation == XtorientVertical) ? w->scrollbar.downCursor : w->scrollbar.rightCursor; break; case 'F': case 'f': cursor = (w->scrollbar.orientation == XtorientVertical) ? w->scrollbar.upCursor : w->scrollbar.leftCursor; break; case 'C': case 'c': cursor = (w->scrollbar.orient<-P XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O- ation == XtorientVertical) ? w->scrollbar.rightCursor : w->scrollbar.upCursor; break; default: return; /* invalid invocation */ } XDefineCursor(XtDisplay(w), XtWindow(w), cursor); XFlush(XtDisplay(w)); } static Boolean CompareEvents( oldEvent, newEvent ) XEvent *oldEvent, *newEvent; { #define Check(field) if (newEvent->field != oldEvent->field) return False; Check(xany.display); Check(xany.type); Check(xany.window); switch( newEvent->type ) { case MotionNotify: Check(xmotion.state); break; case ButtonPress: case ButtonRelease: Check(xbutton.state); Check(xbutton.button); break; case KeyPress: case KeyRelease: Check(xkey.state); Check(xkey.keycode); break; case EnterNotify: case LeaveNotify: Check(xcrossing.mode); Check(xcrossing.detail); Check(xcrossing.state); break; } #undef Check return True; } struct EventData { XEvent *oldEvent; int count; }; static Bool PeekNotifyEvent( dpy, event, args ) Display *dpy; XEvent *event; char *args; { struct EventData *eventData = (struct EventData*)args; return ((++eventData->count == QLength(dpy)) /* since PeekIf blocks */ || CompareEvents(event, eventData->oldEvent)); } static Boolean LookAhead( w, event ) Widget w; XEvent *event; { XEvent newEvent; struct EventData eventData; if (QLength(XtDisplay(w)) == 0) return False; eventData.count = 0; eventData.oldEvent = event; XPeekIfEvent(XtDis? XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O-a#play(w), &newEvent, PeekNotifyEvent, (char*)&eventData); if (CompareEvents(event, &newEvent)) return True; else return False; } static void ExtractPosition( event, x, y ) XEvent *event; Position *x, *y; /* RETURN */ { switch( event->type ) { case MotionNotify: *x = event->xmotion.x; *y = event->xmotion.y; break; case ButtonPress: case ButtonRelease: *x = event->xbutton.x; *y = event->xbutton.y; break; case KeyPress: case KeyRelease: *x = event->xkey.x; *y = event->xkey.y; break; case EnterNotify: case LeaveNotify: *x = event->xcrossing.x; *y = event->xcrossing.y; break; default: *x = 0; *y = 0; } } static void NotifyScroll( gw, event, params, num_params ) Widget gw; XEvent *event; String *params; /* style: Proportional|FullLength */ Cardinal *num_params; /* we only support 1 */ { ScrollbarWidget w = (ScrollbarWidget) gw; int call_data; char style; Position x, y; if (w->scrollbar.direction == 0) return; /* if no StartScroll */ if (LookAhead(gw, event)) return; if (*num_params > 0) style = *params[0]; else style = 'P'; switch( style ) { case 'P': /* Proportional */ case 'p': ExtractPosition( event, &x, &y ); call_data = InRange( PICKLENGTH( w, x, y ), 0, (int) w->scrollbar.length); break; case 'F': /* FullLength */ case 'f': call_data = w->scrollbar.length; break; } switch( w->scrol;ȇ XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O-&lbar.direction ) { case 'B': case 'b': call_data = -call_data; /* fall through */ case 'F': case 'f': XtCallCallbacks( gw, XtNscrollProc, (caddr_t)call_data ); break; case 'C': case 'c': /* NotifyThumb has already called the thumbProc(s) */ break; } } /* ARGSUSED */ static void EndScroll(gw, event, params, num_params ) Widget gw; XEvent *event; /* unused */ String *params; /* unused */ Cardinal *num_params; /* unused */ { ScrollbarWidget w = (ScrollbarWidget) gw; XDefineCursor(XtDisplay(w), XtWindow(w), w->scrollbar.inactiveCursor); XFlush(XtDisplay(w)); w->scrollbar.direction = 0; } /* ARGSUSED */ static void MoveThumb( gw, event, params, num_params ) Widget gw; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { ScrollbarWidget w = (ScrollbarWidget) gw; Position x, y; if (w->scrollbar.direction == 0) return; /* if no StartScroll */ if (LookAhead(gw, event)) return; ExtractPosition( event, &x, &y ); w->scrollbar.top = FractionLoc(w, x, y); PaintThumb(w); XFlush(XtDisplay(w)); /* re-draw it before Notifying */ } /* ARGSUSED */ static void NotifyThumb( gw, event, params, num_params ) Widget gw; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { register ScrollbarWidget w = (ScrollbarWidget) gw; if (w->scrollbar.direction == 0) return; /* if no StartScroll */ if (LookA XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.C;2O-X)head(gw, event)) return; XtCallCallbacks( gw, XtNthumbProc, w->scrollbar.top); XtCallCallbacks( gw, XtNjumpProc, &w->scrollbar.top); } /************************************************************ * * Public routines. * ************************************************************/ /* Set the scroll bar to the given location. */ extern void XawScrollbarSetThumb( gw, top, shown ) Widget gw; float top, shown; { ScrollbarWidget w = (ScrollbarWidget)gw; if (w->scrollbar.direction == 'c') return; /* if still thumbing */ w->scrollbar.top = (top > 1.0) ? 1.0 : (top >= 0.0) ? top : w->scrollbar.top; w->scrollbar.shown = (shown > 1.0) ? 1.0 : (shown >= 0.0) ? shown : w->scrollbar.shown; PaintThumb( w ); } "*[MAHAN.XTERM.LIB.XAW]SCROLLBAR.H;2+,r. /@ 4N 9 F-zr0123KPWO 569 F7P F8Pe9G@HJPmܳWyJ/rk9A2]@{iZUJ;w`96)M;SH1I GG+Q{z2: 9% 5taYKqbR^FpX!P$]53w fDZc-bOE,BfHHw\? H;DOm=6(5=gHUp_RvIp[ #>M ].`qGX)AZj7#x$&"GL=.g#)RnXagJ?En P[pRfp^yB[g {?-R}!]qi\=^sxN\ne6j>go@XHTyAi#/>LR$!9ORaQg,\; n5F' T^{ CO!%0",%^=`CxHd.r#^k%Q5v`m"OLo R&R13 rez0* \>! .0x/A`>E{g^i0\qvlapjzYQ""vAWBfxYfQKn-b(W7:aw[G[4nq^1~_2q@nYXv!An~;#=L 8k;}(bW<,1NyDrA'xVP/1#Cxc}R&tDp=5~1G *(pz^tJ'3z(2P P[6brL,*]y>ej+0GB7? 5{I~s7B3wrG=sBgyW oa)pR 0Bkx6sQs5g}6+&0MP w>g0.J_4&qGoRF8%x1=}i/7<2x,quDU<5PeO9? Tw3~PEBJT|w4]+nESlzDx:fU4% }=OFUih()0zS-)]=0$y Getf5 B>7Hjw':$EwbWjU 50U1L1F3 jlp_v=k}N3my|l4I]3 8|^ /Z6 2~eUb4'GT#oD oonS%)l";d#x|P[4O789Q*9x_<;`EjQWJ AGw1.@3rNis&l96E'/6pojsPw8(dXk`q*6mejo(&Z X#cwB~3y}$} 6c+1((n}#1zjyw7)gM=>-Ef ,jzlYW FJr6jAlhp"JIWzSg`''.1wDc N0up\CzawRkkb:[2=~h/0NRB4U.y &F9{elUj8P9=pjfXjS2*Fq/h*\EP7',SM_8@r5 bt uQp]Xrx(s .o t5*F85KN -qj? `z@906roK[ {)bx~:S>_'jc'P DG=U8RpzV)^M.mu)}wP61=Y5o3b/'tX$K"I9,kj%,/18^ UHOs@;skP8E]4 Gglp%1m<(=/, Z@6mgKz!~Q#l^!,_A}B&3N,HRdc2^3^ +/7 $#Ax66H I@m|s@M UB +*i&D(}Kzy72K#5u~ikFo~*xykjTwj*lngb ^w\!^O& KwF\{Ij&]{<T5H?v4% X qk7v>8aZ7\h#=!{~)B:~#fHhQy1~_v$W^g?6bBm\pJA6 &Jl-g2Pu^vytIh\VSwkY")^tb8|*1,S5q} }pRlU4 L"B,Y7v|!nk!^h2i|o;YqgTsNB?vh;yLZ& k`:DV 7_:\Gޖ. XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.H;2N _/* * $XConsortium: Scrollbar.h,v 1.1 89/12/15 11:40:43 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 _Scrollbar_h #define _Scrollbar_h /**************************************************************** * * Scrollbar Widget * ****************************************************************/ #ifdef vax11c #include #else #include #endif /* vax11c */ /* Parameters: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel White border BorderColor Pixel Black borderWidth BorderWidth Dimension 1 destroyCallback Callback Function NULL foreground Color Pixel Black height Height Dimension length or thickness jumpProc Callback Function NULL length Length Dimension 1 mappedWhenManaged MappedWhenManaged Boolean True orientation Orientation XtOrientation XtorientVertical reverseVideo ReverseVideo Boolean False scrollDCursor Cursor Cursor XC_sb_down_arrow scrollHCursor Cursor Cursor XC_sb_h_double_arrow scrollLCursor Cursor Cursor XC_sb_left_arrow scrollProc Callback Function NULL scrollRCursor Cursor Cursor XC_sb_right_arrow scrollUCursor Cursor Cursor XC_sb_up_arrow scrollVCursor Cursor Cursor XC_sb_v_double_arrow sensitive Sensitive Boolean True shown Shown float 0.0 thickness Thickness Dimension 14 thumb Thumb Pixmap Grey topOfThumb TopOfThumb float 0.0 width Width Dimension thickness or length x Position Position 0 y Position Position 0 */ /* * Most things we need are in StringDefs.h */ #define XtCMinimumThumb "MinimumThumb" #define XtCShown "Shown" #define XtCTopOfThumb "TopOfThumb" #define XtNminimumThumb "minimumThumb" #define XtNtopO| XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]SCROLLBAR.H;2N ,fThumb "topOfThumb" typedef struct _ScrollbarRec *ScrollbarWidget; typedef struct _ScrollbarClassRec *ScrollbarWidgetClass; #ifndef XAW_SCROLLBAR_WIDGET #ifdef vax11c globalref WidgetClass scrollbarWidgetClass; #else extern WidgetClass scrollbarWidgetClass; #endif /* vax11c */ #endif /* !XAW_SCROLLBAR_WIDGET */ extern void XawScrollbarSetThumb(); /* scrollBar, top, shown */ /* Widget scrollBar; */ /* float top, shown; */ #ifdef XAW_BC /************************************************************* * For Compatibility only. */ #define XtScrollBarSetThumb XawScrollbarSetThumb /*************************************************************/ #endif /* XAW_BC */ #endif /* _Scrollbar_h */ #*[MAHAN.XTERM.LIB.XAW]SCROLLBARP.H;2+,r. /@ 4N . F-zr0123KPWO56. F70- F8P)e9G@HJq#O XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SCROLLBARP.H;2N /* * $XConsortium: ScrollbarP.h,v 1.1 89/12/15 11:41:03 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 _ScrollbarP_h #define _ScrollbarP_h #ifdef vax11c #include "Scrollbar.h" #else #include #endif /* vax11c */ typedef struct { /* public */ Pixel foreground; /* thumb foreground color */ X XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SCROLLBARP.H;2N 2tOrientation orientation; /* horizontal or vertical */ XtCallbackList scrollProc; /* proportional scroll */ XtCallbackList thumbProc; /* jump (to position) scroll */ XtCallbackList jumpProc; /* same as thumbProc but pass data by ref */ Pixmap thumb; /* thumb color */ Cursor upCursor; /* scroll up cursor */ Cursor downCursor; /* scroll down cursor */ Cursor leftCursor; /* scroll left cursor */ Cursor rightCursor; /* scroll right cursor */ Cursor verCursor; /* scroll vertical cursor */ Cursor horCursor; /* scroll horizontal cursor */ float top; /* What percent is above the win's top */ float shown; /* What percent is shown in the win */ Dimension length; /* either height or width */ Dimension thickness; /* either width or height */ Dimension min_thumb; /* minium size for the thumb. */ /* private */ Cursor inactiveCursor; /* The normal cursor for scrollbar */ char direction; /* a scroll has started; which direction */ GC gc; /* a (shared) gc */ Position topLoc; /* Pixel that corresponds to top */ Dimension shownLength; /* Num pixels corresponding to shown */ } ScrollbarPart; typedef struct _ScrollbarRec { CorePart core; ScrollbarPart scrollbar; } ScrollbarRec; typedef struct {int empty;} ScrollbarClassPart; typedef struct _ScrollbarClassRec { CoreClassPart core_class; ScrollbarClassPart scrollbar_class; } ScrollbarClassRec; #ifndef XAW_SCROLLBAR_WIDGET #ifdef vax11c gl}tk XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SCROLLBARP.H;2N mobalref ScrollbarClassRec scrollbarClassRec; #else extern ScrollbarClassRec scrollbarClassRec; #endif /* vax11c */ #endif /* !XAW_SCROLLBAR_WIDGET */ #endif /* _ScrollbarP_h */ *[MAHAN.XTERM.LIB.XAW]SIMPLE.C;2+,r./@ 4y w!F-zr0123KPWO56!F7P!F8Z?f9G@HJ#ifndef lint static char Xrcsid[] = "$XConsortium: Simple.c,v 1.26 89/12/18 10:52:32 rws 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, m XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SIMPLE.C;2yprovided 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. ******************************************************************/ #define XAW_SIMPLE_WIDGET #include #ifdef vax11c #include #include #include "XawInit.h" #include "SimpleP.h" #else #include #include #include #include #endif /* vax11c */ #define UnspecifiedPixmap 2 /* %%% should be NULL, according to the spec */ static XtResource resources[] = { #define offset(field) XtOffset(SimpleWidget, simple.field) {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(cursor), XtRImmediate, (caddr_t) None}, {XtNinsensitiveBorder, XtCInsensitive, XtRPixmap, sizeof(Pixmap), offset(insensitive_border), XtRImmediaC XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SIMPLE.C;2yJte, (caddr_t) NULL} #undef offset }; static void ClassPartInitialize(), Realize(); static Boolean SetValues(), ChangeSensitive(); #ifdef vax11c globaldef {"simpleclassrec"} noshare #endif /* vax11c */ SimpleClassRec simpleClassRec = { { /* core fields */ /* superclass */ (WidgetClass) &widgetClassRec, /* class_name */ "Simple", /* widget_size */ sizeof(SimpleRec), /* class_initialize */ XawInitializeWidgetSet, /* class_part_initialize */ ClassPartInitialize, /* class_inited */ FALSE, /* initialize */ NULL, /* 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 */ NULL, /* 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 */ XtInheritQueryGeometry, /* display_accelerator */ XtInheritDisplayAccelerator, /* extension */ NULL }, { /* simple fields */ /* change_sensitive */ ChangeSensitive } }; #ifdef vax11c globaldef {"simplewidgetclass"} noshare #enl. XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SIMPLE.C;23ymIdif /* vax11c */ WidgetClass simpleWidgetClass = (WidgetClass)&simpleClassRec; static void ClassPartInitialize(class) WidgetClass class; { register SimpleWidgetClass c = (SimpleWidgetClass)class; if (c->simple_class.change_sensitive == NULL) { char buf[BUFSIZ]; sprintf(buf, "%s Widget: The Simple Widget class method 'change_sensitive' is undefined.\nA function must be defined or inherited.", c->core_class.class_name); XtWarning(buf); c->simple_class.change_sensitive = ChangeSensitive; } if (c->simple_class.change_sensitive == XtInheritChangeSensitive) c->simple_class.change_sensitive = ChangeSensitive; } static void Realize(w, valueMask, attributes) register Widget w; Mask *valueMask; XSetWindowAttributes *attributes; { Pixmap border_pixmap; if (!XtIsSensitive(w)) { /* change border to gray; have to remember the old one, * so XtDestroyWidget deletes the proper one */ if (((SimpleWidget)w)->simple.insensitive_border == NULL) ((SimpleWidget)w)->simple.insensitive_border = XmuCreateStippledPixmap(XtScreen(w), w->core.border_pixel, w->core.background_pixel, w->core.depth); border_pixmap = w->core.border_pixmap; attributes->border_pixmap = w->core.border_pixmap = ((SimpleWidget)w)->simple.insensitive_border; *valueMask |= CWBorderPixmap; *valueMask &= ~CWBorderPixel; } if ((attributes->cursor = ((SimpleWidget)w)->simple.cursor) != None) *valueMask |= CWCursor; XtCreateWindow( w, (unsigned int)InputOutput$ц- XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SIMPLE.C;23y , (Visual *)CopyFromParent, *valueMask, attributes ); if (!XtIsSensitive(w)) w->core.border_pixmap = border_pixmap; } /* ARGSUSED */ static Boolean SetValues(current, request, new) Widget current, request, new; { SimpleWidget s_old = (SimpleWidget) current; SimpleWidget s_new = (SimpleWidget) new; if ( XtIsSensitive(current) != XtIsSensitive(new) ) (*((SimpleWidgetClass)XtClass(new))-> simple_class.change_sensitive) ( new ); if ( (s_old->simple.cursor != s_new->simple.cursor) && XtIsRealized(new)) XDefineCursor(XtDisplay(new), XtWindow(new), s_new->simple.cursor); return False; } static Boolean ChangeSensitive(w) register Widget w; { if (XtIsRealized(w)) { if (XtIsSensitive(w)) if (w->core.border_pixmap != UnspecifiedPixmap) XSetWindowBorderPixmap( XtDisplay(w), XtWindow(w), w->core.border_pixmap ); else XSetWindowBorder( XtDisplay(w), XtWindow(w), w->core.border_pixel ); else { if (((SimpleWidget)w)->simple.insensitive_border == NULL) ((SimpleWidget)w)->simple.insensitive_border = XmuCreateStippledPixmap(XtScreen(w), w->core.border_pixel, w->core.background_pixel, w->core.depth); XSetWindowBorderPixmap( XtDisplay(w), XtWindow(w), ((SimpleWidget)w)-> simple.insensitive_border ); } } return False; } i~fs 2 _Q(VmRbUi{iyb[q(8o]:oKz4NW|^ QG#CP|52i&*%;-JiX=Ax z6V-)#(x}(FL#GSgh1X$<$<%|r%pE`Kr]d}ardlq`AQ@[i) LN;7Fo'u0:/ <:!1uCdr!InXP" CYH.zn.} JcW ;}}O)_~4hMwwWj2 d)2i*`AU|D},7=K 8kWP\N2Jj<%E`EE-1wR"}:^w\F/wyLtf.{Y7{^3 5,IZ>10(Yof^t E#o +`0$"UR-4FErTjd**NzX W|mR{G!_4\ ?al1=RW1seL3%4Fn~>MCxFHbD|_`;?+'Eu5vq-'~ H6W\DW =`ghzOAQi)for+s-" c !Ch:6M:g;rM#}dh['-!q GA(3k// ,i53}-\u*TW,MV77LmAeGKb R7l\P\p%$JHb5*??33[bG6Z)CQmq:$^"gRh,%^zSZz>f:Y~|o`@hl$~CA Y7W,iI25fp1s<%y aM}=D c=Iyx"dH>lgC5s] =%T|a\{i^~dT88I"V1FT0SOUhR(B:45$a-|seIl'H xg&2#[\L7$FNRl E]Wj+aREwc#1?"t@se7PK(Q^Sr M{oa)"@zP9$xi~^).]SETR!H[zrIn.\q<\H%~#1sI 6|](3"[\Mo$z~7*2/o:ajbg.JV IOmiXZ|O2~x&"'r } 0Ais(3x#0NI17O-() tiFǭo"Q>%uyqUYRo]Nl{tb(&,hUnN jPR6.s>kX;D.+C\9R( +"!#ZSaTq`ryc 2^E`w43 R3:=p*3Gf3~27`W v N"r=Y n4 EVBJ}D;OQR8s_13RK 0]b<~mO0Ta005SMY1dA[u ` +KVV+%&2)DjE}'-ni1w IM2A2\,I"?("%3HDSv~X|4h).q[v!>Hp\A7(Onm2CH(LMBC[]&B_y**/GYbGoy] oi] XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SIMPLE.H;2NO:*[MAHAN.XTERM.LIB.XAW]SIMPLE.H;2+,r./@ 4N F-zr0123KPWO56 F7 F8.pf9G@HJ/* * $XConsortium: Simple.h,v 1.9 89/07/21 01:44:53 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 WhpQ7 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SIMPLE.H;2N6HATSOEVER 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 _Simple_h #define _Simple_h /**************************************************************** * * Simple widgets * ****************************************************************/ /* Resources: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 cursor Cursor Cursor None destroyCallback Callback Pointer NULL height Height Dimension 0 insensitiveBorder Insensitive Pixmap Gray mappedWhenManaged MappedWhenManaged Boolean True sensitive Sensitive Boolean True width Width Dimension 0 x Position Position 0 y Position Position 0 */ #define XtNcursor "cursor" #define XtNinsensitiveBorder "insensitiveBorder" #define XtCInsensitive "Insensitive" typedef struct _SimpleClassRec *SimpleWidgetClass; typedef struct _SimpleRec *SimpleWidget; #ifndef XAW_SIMPLE_WIDGET #ifdef vax11c globalref WidgetClass simpleWidgetClass; #else extern WidgetClass simpleWidgetClass; #endif /* vax11c */ #endif /* !XAW_SIMPLE_WIDGET */ #endif /* _Simple_h */ Z XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENP.H;2O #*[MAHAN.XTERM.LIB.XAW]SIMPLEMENP.H;2+,r. /@ 4O  F-zr0123KPWO 56 F7p$ F87f9G@HJ/* * $XConsortium: SimpleMenP.h,v 1.12 89/12/11 15:01:39 kit Exp $ * * 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 %a  XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENP.H;2O @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. * */ /* * SimpleMenuP.h - Private Header file for SimpleMenu widget. * * Date: April 3, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #ifndef _SimpleMenuP_h #define _SimpleMenuP_h #ifdef vax11c #include "SimpleMenu.h" #include "SmeP.h" #include #else #include #include #include #endif /* vax11c */ #define ForAllChildren(smw, childP) \ for ( (childP) = (SmeObject *) (smw)->composite.children ; \ (childP) < (SmeObject *) ( (smw)->composite.children + \ (smw)->composite.num_children ) ; \ (childP)++ ) typedef struct { XtPointer extension; /* For future needs. */ } SimpleMenuClassPart; typedef struct _SimpleMenuClassRec { CoreClassPart core_class; CompositeClassPart composite_class; ShellClassPart shell_class; OverrideShellClassPart override_shell_class; SimpleMenuClassPart simpleMenu_class; } SimpleMenuClassRec; #ifndef XAW_SIMPLE_MENU_WIDGET #ifdef vax11c globalref SimpleMenuClassRec simpleMenuClassRec; #else extern SimpleMenuClassRec simpleMenuClassRec; #endif /* vax11c */ #endif /* !XAW_SIMPLE_MENU_WIDGET */ typedef struct _SimpleMenuPart { /* resources */ String label_string; /* The string for th^  XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENP.H;2O ݛe label or NULL. */ SmeObject label; /* If label_string is non-NULL then this is the label widget. */ WidgetClass label_class; /* Widget Class of the menu label object. */ Dimension top_margin; /* Top and bottom margins. */ Dimension bottom_margin; Dimension row_height; /* height of each row (menu entry) */ Cursor cursor; /* The menu's cursor. */ SmeObject popup_entry; /* The entry to position the cursor on for when using XawPositionSimpleMenu. */ Boolean menu_on_screen; /* Force the menus to be fully on the screen.*/ int backing_store; /* What type of backing store to use. */ /* private state */ Boolean recursive_set_values; /* contain a possible infinite loop. */ Boolean menu_width; /* If true then force width to remain core.width */ Boolean menu_height; /* Just like menu_width, but for height. */ SmeObject entry_set; /* The entry that is currently set or highlighted. */ } SimpleMenuPart; typedef struct _SimpleMenuRec { CorePart core; CompositePart composite; ShellPart shell; OverrideShellPart override; SimpleMenuPart simple_menu; } SimpleMenuRec; #endif /* _SimpleMenuP_h */ w9 XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WF#*[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2+,r.F/@ 4WFEp\"F-zr0123KPWOF56p\"F7 "F80ǜg9G@HJ#if ( !defined(lint) && !defined(SABER) ) static char Xrcsid[] = "$XConsortium: SimpleMenu.c,v 1.32 89/12/11 15:01:50 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, IN?p XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WF(DIRECT 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. */ /* * SimpleMenu.c - Source code file for SimpleMenu widget. * * Date: April 3, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #define XAW_SIMPLE_MENU_WIDGET #include #ifdef vax11c #include #include #include "XawInit.h" #include "SimpleMenP.h" #include "SmeBSB.h" #include "Cardinals.h" #include #include #else #include #include #include #include #include #include #include #include #endif /* vax11c */ #define streq(a, b) ( strcmp((a), (b)) == 0 ) #define offset(field) XtOffset(SimpleMenuWidget, simple_menu.field) static XtResource resources[] = { /* * Label Resources. */ {XtNlabel, XtCLabel, XtRString, sizeof(String), offset(label_string), XtRString, NULL}, {XtNlabelClass, XtCLabelClass, XtRPointer, sizeof(WidgetClass), offset(label_class), XtRImmediate, (caddr_t) NULL}, /* * Layout Resources. */ {XtNrowHeight, XtCRowHeight, XtRDimension, sizeof(Dimension), offset(row_height), XtRImX|X XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WFvmediate, (caddr_t) 0}, {XtNtopMargin, XtCVerticalMargins, XtRDimension, sizeof(Dimension), offset(top_margin), XtRImmediate, (caddr_t) 0}, {XtNbottomMargin, XtCVerticalMargins, XtRDimension, sizeof(Dimension), offset(bottom_margin), XtRImmediate, (caddr_t) 0}, /* * Misc. Resources */ { XtNallowShellResize, XtCAllowShellResize, XtRBoolean, sizeof(Boolean), XtOffset(SimpleMenuWidget, shell.allow_shell_resize), XtRImmediate, (XtPointer) TRUE }, {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(cursor), XtRImmediate, (caddr_t) None}, {XtNmenuOnScreen, XtCMenuOnScreen, XtRBoolean, sizeof(Boolean), offset(menu_on_screen), XtRImmediate, (caddr_t) TRUE}, {XtNpopupOnEntry, XtCPopupOnEntry, XtRWidget, sizeof(Widget), offset(popup_entry), XtRWidget, NULL}, {XtNbackingStore, XtCBackingStore, XtRBackingStore, sizeof (int), offset(backing_store), XtRImmediate, (caddr_t) (Always + WhenMapped + NotUseful)}, }; #undef offset static char defaultTranslations[] = ": highlight() \n\ : unhighlight() \n\ : highlight() \n\ : MenuPopdown() notify() unhighlight()"; /* * Semi Public function definitions. */ static void Redisplay(), Realize(), Resize(), ChangeManaged(); static void Initialize(), ClassInitialize(), ClassPartInitialize(); static Boolean SetValues(), SetValuesHook(); static XtGeometryResult GeometryManager(); /* * /ȁ8 XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WF Action Routine Definitions */ static void Highlight(), Unhighlight(), Notify(), PositionMenuAction(); /* * Private Function Definitions. */ static void MakeSetValuesRequest(), CreateLabel(), Layout(); static void AddPositionAction(), PositionMenu(), ChangeCursorOnGrab(); static Dimension GetMenuWidth(), GetMenuHeight(); static Widget FindMenu(); static SmeObject GetEventEntry(); static XtActionsRec actionsList[] = { {"notify", Notify}, {"highlight", Highlight}, {"unhighlight", Unhighlight}, }; CompositeClassExtensionRec extension_rec = { /* next_extension */ NULL, /* record_type */ NULLQUARK, /* version */ XtCompositeExtensionVersion, /* record_size */ sizeof(CompositeClassExtensionRec), /* accepts_objects */ TRUE, }; #define superclass (&overrideShellClassRec) #ifdef vax11c globaldef {"simplemenuclassrec"} noshare #endif /* vax11c */ SimpleMenuClassRec simpleMenuClassRec = { { /* superclass */ (WidgetClass) superclass, /* class_name */ "SimpleMenu", /* size */ sizeof(SimpleMenuRec), /* class_initialize */ ClassInitialize, /* class_part_initialize*/ ClassPartInitialize, /* Class init'ed */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ Realize, /* actions */ actionsList, /* num_actions */ XtNumber(actionsList), /* resources */ resources, v8w XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WF /* resource_count */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure */ TRUE, /* compress_enterleave*/ TRUE, /* visible_interest */ FALSE, /* destroy */ NULL, /* resize */ Resize, /* expose */ Redisplay, /* set_values */ SetValues, /* set_values_hook */ SetValuesHook, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* intrinsics version */ XtVersion, /* callback offsets */ NULL, /* tm_table */ defaultTranslations, /* query_geometry */ NULL, /* display_accelerator*/ NULL, /* extension */ NULL },{ /* geometry_manager */ GeometryManager, /* change_managed */ ChangeManaged, /* insert_child */ XtInheritInsertChild, /* delete_child */ XtInheritDeleteChild, /* extension */ NULL },{ /* Shell extension */ NULL },{ /* Override extension */ NULL },{ /* Simple Menu extension*/ NULL } }; #ifdef vax11c globaldef {"simplemenuwidgetclass"} noshare #endif /* vax11c */ WidgetClass simpleMenuWidgetClass = (WidgetClass)&simpleMenuClassRec; /************************************************************ * * Semi-Public Functions. * ************************************************************/ /* Function Name: ClassInitialize * Descripti L "RG8%G5K!%E=w% Hrs4gY]#yFBLh%4~d}Nb~d$Gq{1!+M:D6o ]f%u]U] M/#ZsJJ~AkOt |x3"U^?/SxHFf[4m&,?=FM EFL9Ii1e*c55L'yH nD7s}XbA ^=_RAz~tL+6v97tۅ^9'W>< t`'/'=a*T)s*B"/Q}dKW9oVWQc rK co%,> f'U]a=pm?;,?g*;X}u(r)_gdb:3%ls>G)Tvr)bG#9eo1dRP1 I~Liz4qZWA x_=&WAEyk!ID[80\kI C @o VAmH?EQrw %Z uJE'r~8Gn]Z6MyE\k 30])t6Y7QD XFG!'cvp'ht2^LU3{F 7nf @|e G8YEa= ( ] @E!9N:{r%74|"(.n*i[:HCOz(` {J26$I?:rE D2OyQ!'+U-d )#W6} ?LE4 ` 4% NCi!As@Mm>a+ > B%UYJxQ3* kBz'UAZKnP UX!/]#po 'orE1xVSu.+ gnWz{#~Q6!8!&@Jg`_-Ya_Wum_o'Lkr& ^asaMpqK|&I= vz&A7%73d;Bm8K+3X[{(V]BsV<~ CW|Ms2J"1ky!|i=0\vUh3 \93"g,?50.aUXZ8@val\J2 !*9>ff,Xnh@ m%./23 .B"6={WJ('(7r):"j@N:\7.-aQy15Z{[}6composite_class.extension; smwc->composite_class.extension = (caddr_t) &extension_rec; } /* 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; { SimpleMenuWidget smw = (SimpleMenuWidget) new; XmuCallInitializers(XtWidgetToApplicationContext(new)); if (smw->simple_menu.label_class == NULL) smw->simple_menu.label_class = smeBSBObjectClass; smw->simple_menW^ XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2B;1WFqu.label = NULL; smw->simple_menu.entry_set = NULL; smw->simple_menu.recursive_set_values = FALSE; if (smw->simple_menu.label_string != NULL) CreateLabel(new); smw->simple_menu.menu_width = TRUE; if (smw->core.width == 0) { smw->simple_menu.menu_width = FALSE; smw->core.width = GetMenuWidth(new, NULL); } smw->simple_menu.menu_height = TRUE; if (smw->core.height == 0) { smw->simple_menu.menu_height = FALSE; smw->core.height = GetMenuHeight(new); } /* * Add a popup_callback routine for changing the cursor. */ XtAddCallback(new, XtNpopupCallback, ChangeCursorOnGrab, NULL); } /* Function Name: Redisplay * Description: Redisplays the contents of the widget. * Arguments: w - the simple menu widget. * event - the X event that caused this redisplay. * region - the region the needs to be repainted. * Returns: none. */ /* ARGSUSED */ static void Redisplay(w, event, region) Widget w; XEvent * event; Region region; { SimpleMenuWidget smw = (SimpleMenuWidget) w; SmeObject * entry; SmeObjectClass class; if (region == NULL) XClearWindow(XtDisplay(w), XtWindow(w)); /* * Check and Paint each of the entries - including the label. */ ForAllChildren(smw, entry) { if (!XtIsManaged ( (Widget) *entry)) continue; if (region != NULL) switch(XRectInRegion(region, (int) (*entry)->rectangle.x, (int) (*entry)->rectangle.y, (unsigned int) (*entry)->rectangle.width, ; XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WFR (unsigned int) (*entry)->rectangle.height)) { case RectangleIn: case RectanglePart: break; default: continue; } class = (SmeObjectClass) (*entry)->object.widget_class; if (class->rect_class.expose != NULL) (class->rect_class.expose)( (Widget) *entry, NULL, NULL); } } /* Function Name: Realize * Description: Realizes the widget. * Arguments: w - the simple menu widget. * mask - value mask for the window to create. * attrs - attributes for the window to create. * Returns: none */ static void Realize(w, mask, attrs) Widget w; XtValueMask * mask; XSetWindowAttributes * attrs; { SimpleMenuWidget smw = (SimpleMenuWidget) w; attrs->cursor = smw->simple_menu.cursor; *mask |= CWCursor; if ((smw->simple_menu.backing_store == Always) || (smw->simple_menu.backing_store == NotUseful) || (smw->simple_menu.backing_store == WhenMapped) ) { *mask |= CWBackingStore; attrs->backing_store = smw->simple_menu.backing_store; } else *mask &= ~CWBackingStore; (*superclass->core_class.realize) (w, mask, attrs); } /* Function Name: Resize * Description: Handle the menu being resized bigger. * Arguments: w - the simple menu widget. * Returns: none. */ static void Resize(w) Widget w; { SimpleMenuWidget smw = (SimpleMenuWidget) w; SmeObject * entry; if ( !XtIsRealized(w) ) return; ForAllChildren(smw, entry) /* reset width of all entries. */ if (XtIsManaged( (Wid *#  XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WFget) *entry)) (*entry)->rectangle.width = smw->core.width; Redisplay(w, (XEvent *) NULL, (Region) NULL); } /* Function Name: SetValues * Description: Relayout the menu when one of the resources is changed. * Arguments: current - current state of the widget. * request - what was requested. * new - what the widget will become. * Returns: none */ /* ARGSUSED */ static Boolean SetValues(current, request, new) Widget current, request, new; { SimpleMenuWidget smw_old = (SimpleMenuWidget) current; SimpleMenuWidget smw_new = (SimpleMenuWidget) new; Boolean ret_val = FALSE, layout = FALSE; if (!XtIsRealized(current)) return(FALSE); if (!smw_new->simple_menu.recursive_set_values) { if (smw_new->core.width != smw_old->core.width) { smw_new->simple_menu.menu_width = (smw_new->core.width != 0); layout = TRUE; } if (smw_new->core.height != smw_old->core.height) { smw_new->simple_menu.menu_height = (smw_new->core.height != 0); layout = TRUE; } } if (smw_old->simple_menu.cursor != smw_new->simple_menu.cursor) XDefineCursor(XtDisplay(new), XtWindow(new), smw_new->simple_menu.cursor); if (smw_old->simple_menu.label_string !=smw_new->simple_menu.label_string) if (smw_new->simple_menu.label_string == NULL) /* Destroy. */ XtDestroyWidget(smw_old->simple_menu.label); else if (smw_old->simple_menu.label_string == NULL) /* Create. */ CreateLabel(new); else { ` XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WFk /* Change. */ Arg args[1]; XtSetArg(args[0], XtNlabel, smw_new->simple_menu.label_string); XtSetValues(smw_new->simple_menu.label, args, ONE); } if (smw_old->simple_menu.label_class != smw_new->simple_menu.label_class) XtAppWarning(XtWidgetToApplicationContext(new), "No Dynamic class change of the SimpleMenu Label."); if ((smw_old->simple_menu.top_margin != smw_new->simple_menu.top_margin) || (smw_old->simple_menu.bottom_margin != smw_new->simple_menu.bottom_margin) /* filler................. */ ) { layout = TRUE; ret_val = TRUE; } if (layout) Layout(new, NULL, NULL); return(ret_val); } /* Function Name: SetValuesHook * Description: To handle a special case, this is passed the * actual arguments. * Arguments: w - the menu widget. * arglist - the argument list passed to XtSetValues. * num_args - the number of args. * Returns: none */ /* * If the user actually passed a width and height to the widget * then this MUST be used, rather than our newly calculated width and * height. */ static Boolean SetValuesHook(w, arglist, num_args) Widget w; ArgList arglist; Cardinal *num_args; { register Cardinal i; Dimension width, height; width = w->core.width; height = w->core.height; for ( i = 0 ; i < *num_args ; i++) { if ( streq(arglist[i].name, XtNwidth) ) width = (Dimension) arglist[i].v P} XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WFcalue; if ( streq(arglist[i].name, XtNheight) ) height = (Dimension) arglist[i].value; } if ((width != w->core.width) || (height != w->core.height)) MakeSetValuesRequest(w, width, height); return(FALSE); } /************************************************************ * * Geometry Management routines. * ************************************************************/ /* Function Name: GeometryManager * Description: This is the SimpleMenu Widget's Geometry Manager. * Arguments: w - the Menu Entry making the request. * request - requested new geometry. * reply - the allowed geometry. * Returns: XtGeometry{Yes, No, Almost}. */ static XtGeometryResult GeometryManager(w, request, reply) Widget w; XtWidgetGeometry * request, * reply; { SimpleMenuWidget smw = (SimpleMenuWidget) XtParent(w); SmeObject entry = (SmeObject) w; XtGeometryMask mode = request->request_mode; XtGeometryResult answer; Dimension old_height, old_width; if ( !(mode & CWWidth) && !(mode & CWHeight) ) return(XtGeometryNo); reply->width = request->width; reply->height = request->height; old_width = entry->rectangle.width; old_height = entry->rectangle.height; Layout(w, &(reply->width), &(reply->height) ); /* * Since we are an override shell and have no parent there is no one to * ask to see if this geom change is okay, so I am just going to assume * we can do whatever we want. If you subclass be very careful with this * assumption, it co $ N XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WF o!uld bite you. * * Chris D. Peterson - Sept. 1989. */ if ( (reply->width == request->width) && (reply->height == request->height) ) { if ( mode & XtCWQueryOnly ) { /* Actually perform the layout. */ entry->rectangle.width = old_width; entry->rectangle.height = old_height; } else { Layout(( Widget) smw, NULL, NULL); } answer = XtGeometryDone; } else { entry->rectangle.width = old_width; entry->rectangle.height = old_height; if ( ((reply->width == request->width) && !(mode & CWHeight)) || ((reply->height == request->height) && !(mode & CWWidth)) || ((reply->width == request->width) && (reply->height == request->height)) ) answer = XtGeometryNo; else { answer = XtGeometryAlmost; reply->request_mode = 0; if (reply->width != request->width) reply->request_mode |= CWWidth; if (reply->height != request->height) reply->request_mode |= CWHeight; } } return(answer); } /* Function Name: ChangeManaged * Description: called whenever a new child is managed. * Arguments: w - the simple menu widget. * Returns: none. */ static void ChangeManaged(w) Widget w; { Layout(w, NULL, NULL); } /************************************************************ * * Global Action Routines. * * These actions routines will be added to the application's * global action list. * ************************************************************/ /* Function Name: PositionMenuAction * Description: Positions the simple m S  XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WF$enu widget. * Arguments: w - a widget (no the simple menu widget.) * event - the event that caused this action. * params, num_params - parameters passed to the routine. * we expect the name of the menu here. * Returns: none */ /* ARGSUSED */ static void PositionMenuAction(w, event, params, num_params) Widget w; XEvent * event; String * params; Cardinal * num_params; { Widget menu; XPoint loc; if (*num_params != 1) { char error_buf[BUFSIZ]; sprintf(error_buf, "%s %s", "Xaw - SimpleMenuWidget: position menu action expects only one", "parameter which is the name of the menu."); XtAppWarning(XtWidgetToApplicationContext(w), error_buf); return; } if ( (menu = FindMenu(w, params[0])) == NULL) { char error_buf[BUFSIZ]; sprintf(error_buf, "%s '%s'", "Xaw - SimpleMenuWidget: could not find menu named: ", params[0]); XtAppWarning(XtWidgetToApplicationContext(w), error_buf); return; } switch (event->type) { case ButtonPress: case ButtonRelease: loc.x = event->xbutton.x_root; loc.y = event->xbutton.y_root; PositionMenu(menu, &loc); break; case EnterNotify: case LeaveNotify: loc.x = event->xcrossing.x_root; loc.y = event->xcrossing.y_root; PositionMenu(menu, &loc); break; case MotionNotify: loc.x = event->xmotion.x_root; loc.y = event->xmotion.y_root; PositionMenu(menu, &loc); break; default: PositionMenu(menu,, XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WF' NULL); break; } } /************************************************************ * * Widget Action Routines. * ************************************************************/ /* Function Name: Unhighlight * Description: Unhighlights current entry. * Arguments: w - the simple menu widget. * event - the event that caused this action. * params, num_params - ** NOT USED ** * Returns: none */ /* ARGSUSED */ static void Unhighlight(w, event, params, num_params) Widget w; XEvent * event; String * params; Cardinal * num_params; { SimpleMenuWidget smw = (SimpleMenuWidget) w; SmeObject entry = smw->simple_menu.entry_set; SmeObjectClass class; if ( entry == NULL) return; smw->simple_menu.entry_set = NULL; class = (SmeObjectClass) entry->object.widget_class; (class->sme_class.unhighlight) ( (Widget) entry); } /* Function Name: Highlight * Description: Highlights current entry. * Arguments: w - the simple menu widget. * event - the event that caused this action. * params, num_params - ** NOT USED ** * Returns: none */ /* ARGSUSED */ static void Highlight(w, event, params, num_params) Widget w; XEvent * event; String * params; Cardinal * num_params; { SimpleMenuWidget smw = (SimpleMenuWidget) w; SmeObject entry; SmeObjectClass class; if ( !XtIsSensitive(w) ) return; entry = GetEventEntry(w, event); if (entry == smw->simple_menu.e9 XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2DES.HINT;1WFa*ntry_set) return; Unhighlight(w, event, params, num_params); if (entry == NULL) return; if ( !XtIsSensitive( (Widget) entry)) { smw->simple_menu.entry_set = NULL; return; } smw->simple_menu.entry_set = entry; class = (SmeObjectClass) entry->object.widget_class; (class->sme_class.highlight) ( (Widget) entry); } /* Function Name: Notify * Description: Notify user of current entry. * Arguments: w - the simple menu widget. * event - the event that caused this action. * params, num_params - ** NOT USED ** * Returns: none */ /* ARGSUSED */ static void Notify(w, event, params, num_params) Widget w; XEvent * event; String * params; Cardinal * num_params; { SimpleMenuWidget smw = (SimpleMenuWidget) w; SmeObject entry = smw->simple_menu.entry_set; SmeObjectClass class; if ( (entry == NULL) || !XtIsSensitive((Widget) entry) ) return; class = (SmeObjectClass) entry->object.widget_class; (class->sme_class.notify)( (Widget) entry ); } /************************************************************ * * Public Functions. * ************************************************************/ /* Function Name: XawSimpleMenuAddGlobalActions * Description: adds the global actions to the simple menu widget. * Arguments: app_con - the appcontext. * Returns: none. */ void XawSimpleMenuAddGlobalActions(app_con) XtAppContext app_con; { XtInitializeWidgetClass(simpleMenuWidgetClass); XmuCallInitializeM9~b.HINT;1kXH<{zfCF"%>b)$KR,{yNG@Q^W#Y!QusSSHK,rA_Sy5#L2?~P9Z2SaF!O~~#e a M&iW &A@c|lNG=Brg,%DJL'Xt v1ui _ 64zp@Z0#r"_kHG ;,!Rb}^#\@1U2k]EtrNcMU8&rFi}Uz=.-.3[}0y/7 E9{5+_01|,gJ9M_UP~C ~^,EX)R_L'.aTB@ &j6/|tVWa'{Nn h8ktbdvd,o/we||(GEwO7Cdzj)m,[oSi ilcZjd#UJph:e)* B0im 7 t@mO}gS{Bphn>9J.USr~C}ZW =$cXgBc$D%GkzK- 3$' 34 n=5TP!2}QWugX(.(TG,pO4` Hw%V%t_h%:o|FN_iF]|[3VWlpPMtM[a'`0cb [a$/.L]H]vrNTbFOW* 0{ 33dCE Lz xcb~&Y08p*1'h8"Nqf)8ROEe#yU@l13CF#!*x:_2.&l @Ys e)Ec "iJTA=3Y +9w9},:en :l7{SxWg* {BXVywE}1d )4xlb&9%_MyvdW9J%;QJU!C3yl$O6DOO_wJI+[QhA8BO=z]uW!h$#[0v'hP SOHvJb e bg(vNl_nYJgdUmL!'W1hF`('C&ns">Yvr ZOAAMHq^2 vzw}dGi*sy eX'<NU|qAF)Ew6~P50o }@>~W1nO#U5ZmLSCSX\}#b_&mX@#bMNcTO/[\n?|:SAYuy(a``7xO& `  UtQ|hp5?kP8^9=n{$fO*6}4f3NPmSF {$g(K(H G]~UR&34[%.V^fz'iQM2fl [ti $IB\r3l~2OB0?+W<(ens&9m w/\/WN[(yRty9({TaEw ;'(V|N`NzV*hzm{|PyjFhP hPsn3-gF6jnwxZfxs a{EVp53KtQyj=:*YU:\PpKwpV>oYMCXFhN/h B:UjB[N , % #QDf5aYZ{UG y:!Dx[z>ME=6X.m38%LwB `<H}fo9PJ&foU1 QqLevbD= m~WPlqBNfA.IRlR> r{ZDQ.YEbGjOf?*l1l%ry4l@ (p*^OEbu-eZS;8gW~; 6C)YC,$Z\IsP4;AlCuo {n[]D?)"FYSNwd#HAH:]ff]L#k* XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WF-rs( app_con ); } /* Function Name: XawSimpleMenuGetActiveEntry * Description: Gets the currently active (set) entry. * Arguments: w - the smw widget. * Returns: the currently set entry or NULL if none is set. */ Widget XawSimpleMenuGetActiveEntry(w) Widget w; { SimpleMenuWidget smw = (SimpleMenuWidget) w; return( (Widget) smw->simple_menu.entry_set); } /* Function Name: XawSimpleMenuClearActiveEntry * Description: Unsets the currently active (set) entry. * Arguments: w - the smw widget. * Returns: none. */ void XawSimpleMenuClearActiveEntry(w) Widget w; { SimpleMenuWidget smw = (SimpleMenuWidget) w; smw->simple_menu.entry_set = NULL; } /************************************************************ * * Private Functions. * ************************************************************/ /* Function Name: CreateLabel * Description: Creates a the menu label. * Arguments: w - the smw widget. * Returns: none. * * Creates the label object and makes sure it is the first child in * in the list. */ static void CreateLabel(w) Widget w; { SimpleMenuWidget smw = (SimpleMenuWidget) w; register Widget * child, * next_child; register int i; Arg args[2]; if ( (smw->simple_menu.label_string == NULL) || (smw->simple_menu.label != NULL) ) { char error_buf[BUFSIZ]; sprintf(error_buf, "Xaw Simple Menu Widget: %s or %s, %s", "label string is NULL", "label already exists", "no label is being created."); XtAppWarning(XtWidgetToApplicationContext(w), error_bu  XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WFA/0f); return; } XtSetArg(args[0], XtNlabel, smw->simple_menu.label_string); XtSetArg(args[1], XtNjustify, XtJustifyCenter); smw->simple_menu.label = (SmeObject) XtCreateManagedWidget("menuLabel", smw->simple_menu.label_class, w, args, TWO); next_child = NULL; for (child = smw->composite.children + smw->composite.num_children, i = smw->composite.num_children ; i > 0 ; i--, child--) { if (next_child != NULL) *next_child = *child; next_child = child; } *child = (Widget) smw->simple_menu.label; } /* Function Name: Layout * Description: lays the menu entries out all nice and neat. * Arguments: w - See below (+++) * width_ret, height_ret - The returned width and * height values. * Returns: none. * * if width == NULL || height == NULL then it assumes the you do not care * about the return values, and just want a relayout. * * if this is not the case then it will set width_ret and height_ret * to be width and height that the child would get if it were layed out * at this time. * * +++ "w" can be the simple menu widget or any of its object children. */ static void Layout(w, width_ret, height_ret) Widget w; Dimension *width_ret, *height_ret; { SmeObject current_entry, *entry; SimpleMenuWidget smw; Dimension width, height; Boolean do_layout = ((height_ret == NULL) || (width_ret == NULL)); Boolean allow_change_size; height = 0; if ( XtIsS3j XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WFܶ3ubclass(w, simpleMenuWidgetClass) ) { smw = (SimpleMenuWidget) w; current_entry = NULL; } else { smw = (SimpleMenuWidget) XtParent(w); current_entry = (SmeObject) w; } allow_change_size = (!XtIsRealized((Widget)smw) || (smw->shell.allow_shell_resize)); if ( smw->simple_menu.menu_height ) height = smw->core.height; else if (do_layout) { height = smw->simple_menu.top_margin; ForAllChildren(smw, entry) { if (!XtIsManaged( (Widget) *entry)) continue; if ( (smw->simple_menu.row_height != 0) && (*entry != smw->simple_menu.label) ) (*entry)->rectangle.height = smw->simple_menu.row_height; (*entry)->rectangle.y = height; (*entry)->rectangle.x = 0; height += (*entry)->rectangle.height; } height += smw->simple_menu.bottom_margin; } else { if ((smw->simple_menu.row_height != 0) && (current_entry != smw->simple_menu.label) ) height = smw->simple_menu.row_height; } if (smw->simple_menu.menu_width) width = smw->core.width; else if ( allow_change_size ) width = GetMenuWidth((Widget) smw, (Widget) current_entry); else width = smw->core.width; if (do_layout) { ForAllChildren(smw, entry) if (XtIsManaged( (Widget) *entry)) (*entry)->rectangle.width = width; if (allow_change_size) MakeSetValuesRequest((Widget) smw, width, height); } else { *width_ret = width; if (height != 0) *height_ret = height; } } /* Function Name: AddPositionAction * Description: Adds the XawPositio` XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WF 6nSimpleMenu action to the global * action list for this appcon. * Arguments: app_con - the application context for this app. * data - NOT USED. * Returns: none. */ /* ARGSUSED */ static void AddPositionAction(app_con, data) XtAppContext app_con; caddr_t data; { static XtActionsRec pos_action[] = { { "XawPositionSimpleMenu", PositionMenuAction }, }; XtAppAddActions(app_con, pos_action, XtNumber(pos_action)); } /* Function Name: FindMenu * Description: Find the menu give a name and reference widget. * Arguments: widget - reference widget. * name - the menu widget's name. * Returns: the menu widget or NULL. */ static Widget FindMenu(widget, name) Widget widget; String name; { register Widget w, menu; for ( w = widget ; w != NULL ; w = XtParent(w) ) if ( (menu = XtNameToWidget(w, name)) != NULL ) return(menu); return(NULL); } /* Function Name: PositionMenu * Description: Places the menu * Arguments: w - the simple menu widget. * location - a pointer the the position or NULL. * Returns: none. */ static void PositionMenu(w, location) Widget w; XPoint * location; { SimpleMenuWidget smw = (SimpleMenuWidget) w; SmeObject entry; XPoint t_point; static void MoveMenu(); if (location == NULL) { Window junk1, junk2; int root_x, root_y, junkX, junkY; unsigned int junkM; location = &t_point; if (XQueryPointer(XtDisplay(w), XtWindow(w), &junk1, &junk2, &root_xf XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WF#9, &root_y, &junkX, &junkY, &junkM) == FALSE) { char error_buf[BUFSIZ]; sprintf(error_buf, "%s %s", "Xaw - SimpleMenuWidget:", "Could not find location of mouse pointer"); XtAppWarning(XtWidgetToApplicationContext(w), error_buf); return; } location->x = (short) root_x; location->y = (short) root_y; } /* * The width will not be correct unless it is realized. */ XtRealizeWidget(w); location->x -= (Position) w->core.width/2; if (smw->simple_menu.popup_entry == NULL) entry = smw->simple_menu.label; else entry = smw->simple_menu.popup_entry; if (entry != NULL) location->y -= entry->rectangle.y + entry->rectangle.height/2; MoveMenu(w, (Position) location->x, (Position) location->y); } /* Function Name: MoveMenu * Description: Actually moves the menu, may force it to * to be fully visable if menu_on_screen is TRUE. * Arguments: w - the simple menu widget. * x, y - the current location of the widget. * Returns: none */ static void MoveMenu(w, x, y) Widget w; Position x, y; { Arg arglist[2]; Cardinal num_args = 0; SimpleMenuWidget smw = (SimpleMenuWidget) w; if (smw->simple_menu.menu_on_screen) { int width = w->core.width + 2 * w->core.border_width; int height = w->core.height + 2 * w->core.border_width; if (x < 0) x = 0; else { int scr_width = WidthOfScreen(XtScreen(w)); if (x + width > scr_width) x = scr_width - width; } if (y < 0) 7cu XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WF3< y = 0; else { int scr_height = HeightOfScreen(XtScreen(w)); if (y + height > scr_height) y = scr_height - height; } } XtSetArg(arglist[num_args], XtNx, x); num_args++; XtSetArg(arglist[num_args], XtNy, y); num_args++; XtSetValues(w, arglist, num_args); } /* Function Name: ChangeCursorOnGrab * Description: Changes the cursor on the active grab to the one * specified in out resource list. * Arguments: w - the widget. * junk, garbage - ** NOT USED **. * Returns: None. */ /* ARGSUSED */ static void ChangeCursorOnGrab(w, junk, garbage) Widget w; caddr_t junk, garbage; { SimpleMenuWidget smw = (SimpleMenuWidget) w; /* * The event mask here is what is currently in the MIT implementation. * There really needs to be a way to get the value of the mask out * of the toolkit (CDP 5/26/89). */ XChangeActivePointerGrab(XtDisplay(w), ButtonPressMask|ButtonReleaseMask, smw->simple_menu.cursor, CurrentTime); } /* Function Name: MakeSetValuesRequest * Description: Makes a (possibly recursive) call to SetValues, * I take great pains to not go into an infinite loop. * Arguments: w - the simple menu widget. * width, height - the size of the ask for. * Returns: none */ static void MakeSetValuesRequest(w, width, height) Widget w; Dimension width, height; { SimpleMenuWidget smw = (SimpleMenuWidget) w; Arg arglist[2]; Cardinal num_args  XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WFP?= (Cardinal) 0; if ( !smw->simple_menu.recursive_set_values ) { if ( (smw->core.width != width) || (smw->core.height != height) ) { smw->simple_menu.recursive_set_values = TRUE; XtSetArg(arglist[num_args], XtNwidth, width); num_args++; XtSetArg(arglist[num_args], XtNheight, height); num_args++; XtSetValues(w, arglist, num_args); } else if (XtIsRealized( (Widget) smw)) Redisplay((Widget) smw, (XEvent *) NULL, (Region) NULL); } smw->simple_menu.recursive_set_values = FALSE; } /* Function Name: GetMenuWidth * Description: Sets the length of the widest entry in pixels. * Arguments: w - the simple menu widget. * Returns: width of menu. */ static Dimension GetMenuWidth(w, w_ent) Widget w, w_ent; { SmeObject cur_entry = (SmeObject) w_ent; SimpleMenuWidget smw = (SimpleMenuWidget) w; Dimension width, widest = (Dimension) 0; SmeObject * entry; if ( smw->simple_menu.menu_width ) return(smw->core.width); ForAllChildren(smw, entry) { XtWidgetGeometry preferred; if (!XtIsManaged( (Widget) *entry)) continue; if (*entry != cur_entry) { XtQueryGeometry(*entry, NULL, &preferred); if (preferred.request_mode & CWWidth) width = preferred.width; else width = (*entry)->rectangle.width; } else width = (*entry)->rectangle.width; if ( width > widest ) widest = width; } return(widest); } /* Function Name: GetMenuHeight * Description: Sets the length of the widest 1/@ XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WFBentry in pixels. * Arguments: w - the simple menu widget. * Returns: width of menu. */ static Dimension GetMenuHeight(w) Widget w; { SimpleMenuWidget smw = (SimpleMenuWidget) w; SmeObject * entry; Dimension height; if (smw->simple_menu.menu_height) return(smw->core.height); height = smw->simple_menu.top_margin + smw->simple_menu.bottom_margin; if (smw->simple_menu.row_height == 0) ForAllChildren(smw, entry) if (XtIsManaged ((Widget) *entry)) height += (*entry)->rectangle.height; else height += smw->simple_menu.row_height * smw->composite.num_children; return(height); } /* Function Name: GetEventEntry * Description: Gets an entry given an event that has X and Y coords. * Arguments: w - the simple menu widget. * event - the event. * Returns: the entry that this point is in. */ static SmeObject GetEventEntry(w, event) Widget w; XEvent * event; { Position x_loc, y_loc; SimpleMenuWidget smw = (SimpleMenuWidget) w; SmeObject * entry; switch (event->type) { case MotionNotify: x_loc = event->xmotion.x; y_loc = event->xmotion.y; break; case EnterNotify: case LeaveNotify: x_loc = event->xcrossing.x; y_loc = event->xcrossing.y; break; case ButtonPress: case ButtonRelease: x_loc = event->xbutton.x; y_loc = event->xbutton.y; break; default: XtAppError(XtWidgetToApplicationContext(w), "Unknown event type in GetEventEntry()."); break; } ifr XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.C;2WFIE ( (x_loc < 0) || (x_loc >= smw->core.width) || (y_loc < 0) || (y_loc >= smw->core.height) ) return(NULL); ForAllChildren(smw, entry) { if (!XtIsManaged ((Widget) *entry)) continue; if ( ((*entry)->rectangle.y < y_loc) && ((*entry)->rectangle.y + (*entry)->rectangle.height > y_loc) ) if ( *entry == smw->simple_menu.label ) return(NULL); /* cannot select the label. */ else return(*entry); } return(NULL); } #*[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.H;2+,r. /@ 4O  F-zr0123KPWO 56 F7Θ F8Ig9G@HJ/* * $XConsortium: SimpleMenu.h,v 1.17 89/12/11 15:01:55 kit Exp $ * * 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 * publicitO XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.H;2O y 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 D. Peterson, MIT X Consortium */ /* * SimpleMenu.h - Public Header file for SimpleMenu widget. * * This is the public header file for the Athena SimpleMenu widget. * It is intended to provide one pane pulldown and popup menus within * the framework of the X Toolkit. As the name implies it is a first and * by no means complete implementation of menu code. It does not attempt to * fill the needs of all applications, but does allow a resource oriented * interface to menus. * * Date: April 3, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #ifndef _SimpleMenu_h #define _SimpleMenu_h #ifdef vax11c #include #include #else #include #include #endif /* vax $ LE'-\$6W !+x"k;=:}(T1chuckP`JCz.O}6+H 5UF _{^BYT]"pPNLatk5DtQMYC=Pj?|,4 V&o>vI<&%0^u;1.iN&3u2(=E9gs1p'*\P1+iqqP-8dw\-O J% c'\ 2m)=yj}uIJFQY/iD:7('[3#E882"SV`Ql{Z,]&%Y}X6`@S/cjJe%8|J]M:eIYU$NHK&%w"@0z !taW+XS,t &ue  9h'5Mb\ Ik>y v-F"F)XT2Lq[a6ZKUIId"pd oJScg]X J?XA:Q\[/ Lr+| }7kP*y`e OB2XRZ=/l!Pn`oIau1=}*YoVghad24'Ccr}#QK:8-zR|Ph(VYW?`K) i<{of>~j|٧nc|J;4G}Ga 2dlbH_Ek+f+5W[s:f rXGk1 vmf.[pFurNL09jE-W0UQh{pr96697Xy$sK#,KrkL:Vtm#X"l{9)2CUA8&HCnA=!";8}U;*$C %{m3 aYuXS )|e"B4 + 9ASe ISCDFOP V @"*MUv0yJ5vT/\Wk] LXm )3Hh(SE,-7wS)!}*H,dXO5*Z8kzFR! #`j8#;LXEE4$d(x]`JB}ARXMikRTtS`|<8tpJ}jDm~Mg~w Yv GWguj<1j c6+s'~ 1> V|MG*4$Dk)_ LM?65e*oj?WL=%U 47,/&~,8P\B%%H^cc`daz2#0[S+ Tpk&mOPKH^J}Xr),6atm0hN*0uutQu.%UsV0^!ee6I XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.H;2;1O 311c */ /**************************************************************** * * SimpleMenu widget * ****************************************************************/ /* SimpleMenu Resources: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground backgroundPixmap BackgroundPixmap Pixmap None borderColor BorderColor Pixel XtDefaultForeground borderPixmap BorderPixmap Pixmap None borderWidth BorderWidth Dimension 1 bottomMargin VerticalMargins Dimension VerticalSpace columnWidth ColumnWidth Dimension Width of widest text cursor Cursor Cursor None destroyCallback Callback Pointer NULL height Height Dimension 0 label Label String NULL (No label) labelClass LabelClass Pointer smeBSBObjectClass mappedWhenManaged MappedWhenManaged Boolean True rowHeight RowHeight Dimension Height of Font sensitive Sensitive Boolean True topMargin VerticalMargins Dimension VerticalSpace width Width Dimension 0 x Position Position 0n y Position Position 0 */ typedef struct _SimpleMenuClassRec* SimpleMenuWidgetClass; typedef struct _SimpleMenuRec* SimpleMenuWidget; #ifndef XAW_SIMPLE_MENU_WIDGET #ifdef vax11c globalref WidgetClass simpleMenuWidgetClass; #else extern WidgetClass simple[  XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]SIMPLEMENU.H;2;1O MenuWidgetClass; #endif /* vax11c */ #endif /* !XAW_SIMPLE_MENU_WIDGET */ #define XtNcursor "cursor" #define XtNbottomMargin "bottomMargin" #define XtNcolumnWidth "columnWidth" #define XtNlabelClass "labelClass" #define XtNmenuOnScreen "menuOnScreen" #define XtNpopupOnEntry "popupOnEntry" #define XtNrowHeight "rowHeight" #define XtNtopMargin "topMargin" #define XtCColumnWidth "ColumnWidth" #define XtCLabelClass "LabelClass" #define XtCMenuOnScreen "MenuOnScreen" #define XtCPopupOnEntry "PopupOnEntry" #define XtCRowHeight "RowHeight" #define XtCVerticalMargins "VerticalMargins" /************************************************************ * * Public Functions. * ************************************************************/ /* Function Name: XawSimpleMenuAddGlobalActions * Description: adds the global actions to the simple menu widget. * Arguments: app_con - the appcontext. * Returns: none. */ void XawSimpleMenuAddGlobalActions(/* app_con */); /* XtAppContext app_con; */ /* Function Name: XawSimpleMenuGetActiveEntry * Description: Gets the currently active (set) entry. * Arguments: w - the smw widget. * Returns: the currently set entry or NULL if none is set. */ Widget XawSimpleMenuGetActiveEntry( /* w */); /* Widget w; */ /* Function Name: XawSimpleMenuClearActiveEntry * Description: Unsets the currently active (set) entry. * Arguments: w - the smw widget. * Returns: none. */ void XawSimpleMenuClearActiveEntry(/* w */); /* Widget w; */ #endif /* _SimpleMenu_h */ 3ϣi XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]SIMPLEP.H;20N *[MAHAN.XTERM.LIB.XAW]SIMPLEP.H;2+,r ./@ 4NN^ F-zr0123KPWO56^ F7i F8h9G@HJ/*********************************************************** $XConsortium: SimpleP.h,v 1.9 89/05/11 01:06: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 DAMAGES WHATSOElH XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]SIMPLEP.H;2R;1NVER 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 _SimpleP_h #define _SimpleP_h #ifdef vax11c #include "Simple.h" #else #include #endif /* vax11c */ /* #include */ typedef struct { Boolean (*change_sensitive)(/* widget */); } SimpleClassPart; #define XtInheritChangeSensitive ((Boolean (*)())_XtInherit) typedef struct _SimpleClassRec { CoreClassPart core_class; SimpleClassPart simple_class; } SimpleClassRec; #ifndef XAW_SIMPLE_WIDGET #ifdef vax11c globalref SimpleClassRec simpleClassRec; #else extern SimpleClassRec simpleClassRec; #endif /* vax11c */ #endif /* !XAW_SIMPLE_WIDGET */ typedef struct { /* resources */ Cursor cursor; Pixmap insensitive_border; /* private state */ } SimplePart; typedef struct _SimpleRec { CorePart core; SimplePart simple; } SimpleRec; #endif /* _SimpleP_h */  . XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]SME.C;2;5MAR;1OY*[MAHAN.XTERM.LIB.XAW]SME.C;2+,r ./@ 4Od"F-zr0123KPWO56"F7#F8^h9G@HJ#if ( !defined(lint) && !defined(SABER) ) static char Xrcsid[] = "$XConsortium: Sme.c,v 1.6 89/12/11 15:20:07 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 O!x XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]SME.C;2;5MAR;1ODR 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. */ /* * Sme.c - Source code for the generic menu entry * * Date: September 26, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #define XAW_SME_OBJECT #include #ifdef vax11c #include #include #include "XawInit.h" #include "SmeP.h" #include "Cardinals.h" #else #include #include #include #include #include #endif /* vax11c */ #define offset(field) XtOffset(SmeObject, sme.field) static XtResource resources[] = { {XtNcallback, XtCCallback, XtRCallback, sizeof(caddr_t), offset(callbacks), XtRCallback, (caddr_t)NULL}, }; #undef offset /* * Semi Public function definitions. */ static void Unhighlight(), Highlight(), Notify(), ClassPartInitialize(); static void Initialize(); static XtGeometryResult QueryGeometry(); #define SUPERCLASS (&rectObjClassRec) #ifdef vax11c globaldef {"smeclassrec"} noshare #endif /* vax11c */ SmeClassRec smeClassRec = { { /* superclass */ (WidgetClass) SUPERCLASS, /* class_name */ "Sme", /* size */ sizeof(SmeRec), /* class_initialize */ XawIn"{ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]SME.C;2;5.;1OitializeWidgetSet, /* class_part_initialize*/ ClassPartInitialize, /* Class init'ed */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ NULL, /* actions */ NULL, /* num_actions */ ZERO, /* resources */ resources, /* resource_count */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ FALSE, /* compress_exposure */ FALSE, /* compress_enterleave*/ FALSE, /* visible_interest */ FALSE, /* destroy */ NULL, /* resize */ NULL, /* expose */ NULL, /* set_values */ NULL, /* set_values_hook */ NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* intrinsics version */ XtVersion, /* callback offsets */ NULL, /* tm_table */ NULL, /* query_geometry */ QueryGeometry, /* display_accelerator*/ NULL, /* extension */ NULL },{ /* Simple Menu Entry Fields */ /* highlight */ Highlight, /* unhighlight */ Unhighlight, /* notify */ Notify, /* extension */ NULL } }; #ifdef vax11c globaldef {"smeobjectclass"} noshare #endif /* vax11c */ WidgetClass smeObjectClass = (WidgetClass) &smeClassRec; /************************************************************#,d XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]SME.C;2;5.;1OF * * Semi-Public Functions. * ************************************************************/ /* Function Name: ClassPartInitialize * Description: handles inheritance of class functions. * Arguments: class - the widget classs of this widget. * Returns: none. */ static void ClassPartInitialize(class) WidgetClass class; { SmeObjectClass m_ent, superC; m_ent = (SmeObjectClass) class; superC = (SmeObjectClass) m_ent->rect_class.superclass; /* * We don't need to check for null super since we'll get to TextSink * eventually. */ if (m_ent->sme_class.highlight == XtInheritHighlight) m_ent->sme_class.highlight = superC->sme_class.highlight; if (m_ent->sme_class.unhighlight == XtInheritUnhighlight) m_ent->sme_class.unhighlight = superC->sme_class.unhighlight; if (m_ent->sme_class.notify == XtInheritNotify) m_ent->sme_class.notify = superC->sme_class.notify; } /* 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. * * MENU ENTRIES CANNOT HAVE BORDERS. */ /* ARGSUSED */ static void Initialize(request, new) Widget request, new; { SmeObject entry = (SmeObject) new; entry->rectangle.border_width = 0; } /* Function Name: Highlight * Description: The default highlight proceedure for menu entries. * Arguments: w - the menu $դ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]SME.C;2;5;1O entry. * Returns: none. */ /* ARGSUSED */ static void Highlight(w) Widget w; { /* This space intentionally left blank. */ } /* Function Name: Unhighlight * Description: The default unhighlight proceedure for menu entries. * Arguments: w - the menu entry. * Returns: none. */ /* ARGSUSED */ static void Unhighlight(w) Widget w; { /* This space intentionally left blank. */ } /* Function Name: Notify * Description: calls the callback proceedures for this entry. * Arguments: w - the menu entry. * Returns: none. */ static void Notify(w) Widget w; { XtCallCallbacks(w, XtNcallback, NULL); } /* Function Name: QueryGeometry. * Description: Returns the preferred geometry for this widget. * Arguments: w - the menu entry object. * itended, return - the intended and return geometry info. * Returns: A Geometry Result. * * See the Intrinsics manual for details on what this function is for. * * I just return the height and a width of 1. */ static XtGeometryResult QueryGeometry(w, intended, return_val) Widget w; XtWidgetGeometry *intended, *return_val; { SmeObject entry = (SmeObject) w; Dimension width; XtGeometryResult ret_val = XtGeometryYes; XtGeometryMask mode = intended->request_mode; width = 1; /* we can be really small. */ if ( ((mode & CWWidth) && (intended->width != width)) || !(mode & CWWidth) ) { return_val->request_mode |= CWWidth; return_val->width = width; mode = return_val->request_mode; if ( (mode & CWWidth) && (width == entry->re%D` XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]SME.C;2;5O5`ctangle.width) ) return(XtGeometryNo); return(XtGeometryAlmost); } return(ret_val); } *[MAHAN.XTERM.LIB.XAW]SME.H;2+,r./@ 4Ope1F-zr0123KPWO56pe1F7}TF8PWh9G@HJ/* * $XConsortium: Sme.h,v 1.4 89/12/11 15:20:09 kit Exp $ * * 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 pertai&q;1b;1vM3QMQ<+Ule0-Oya\U8_?mah ^7j<fv,#&{|9$K!&l00E;IRT7:^5di@C9ETN# p1n'G $w@'}  5%/~fyzs84-<q! ,nL<loe8D%rZqE> 1"7r h8J18C?qpes%GIWT{&o K>Aj}+fh>$K)6Mh65E%xb6i3:Bg)2JtfXLKf|%C0g Q(yh -:e/_DVnQ pgE+&w>E / $ 3*{a!\2YAG(kr 581(~,CpQF]"71e$CDwk4 'r|*(?Kx5m-C|^&f?i{G6#h! =$[z64F[1)Ua4@ywm3HS1}lcblZ569 Coo*<TIO`DoyR)t?zcxAs|`tr ;<> y12?Dm_b+M= %!*)'igrn6~Tbstv0gxL[OO"h J U1zE A*ecom39~m8%PoX3\'p!<[dkg}Z3J`~2_5sx1?$QsJUj8coki:q9U|x#_)|E%*#nzY #s ybF#o2:bBr]Ms5] ,B!{o7zocP[bg.78onsvkhu4n}d' XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SME.H;2H;4Oning 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. */ /* * Sme.h - Public Header file for Sme object. * * This is the public header file for the Athena Sme object. * It is intended to be used with the simple menu widget. * * Date: April 3, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #ifndef _Sme_h #define _Sme_h #ifdef vax11c #include #else #include #endif /* vax11c */ /**************************************************************** * * Sme Object * ****************************************************************/ /* Simple Menu Entry Resources: Name Class RepType Default Value ---- ----- ------- ------------- callback Callback Pointer NULL destroyCallback Callback Pointer NULL height Height Dimension 0 sensit(ќ] XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SME.H;2H;4O.ive Sensitive Boolean True width Width Dimension 0 x Position Position 0n y Position Position 0 */ typedef struct _SmeClassRec* SmeObjectClass; typedef struct _SmeRec* SmeObject; #ifndef XAW_SME_OBJECT #ifdef vax11c globalref WidgetClass smeObjectClass; #else extern WidgetClass smeObjectClass; #endif /* vax11c */ #endif /* !XAW_SME_OBJECT */ #endif /* _Sme_h */ *[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2+,r.(/@ 4R(%$F-zr0123KPWO&56$F7W$F8i9G@HJ#if ( !defined(lint) && !defined(SABER) ) static char Xrcsid[] = "$XConsortium: SmeBSB.c,v 1.9 89/12/13 15:42:48 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)3t3g XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2R(U) 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. */ /* * SmeBSB.c - Source code file for BSB Menu Entry object. * * Date: September 26, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #define XAW_SME_BSB_OBJECT #include #ifdef vax11c #include #include #include #include "XawInit.h" #include "SimpleMenu.h" #include "SmeBSBP.h" #include "Cardinals.h" #else #include #include #include #include #include #include #include #endif /* vax11c */ #define ONE_HUNDRED 100 #define offset(field) XtOffset(SmeBSBObject, sme_bsb*ЉsB XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2C;2R(C.field) static XtResource resources[] = { {XtNlabel, XtCLabel, XtRString, sizeof(String), offset(label), XtRString, NULL}, {XtNvertSpace, XtCVertSpace, XtRInt, sizeof(int), offset(vert_space), XtRImmediate, (caddr_t) 25}, {XtNleftBitmap, XtCLeftBitmap, XtRPixmap, sizeof(Pixmap), offset(left_bitmap), XtRImmediate, (caddr_t)None}, {XtNjustify, XtCJustify, XtRJustify, sizeof(XtJustify), offset(justify), XtRImmediate, (caddr_t) XtJustifyLeft}, {XtNrightBitmap, XtCRightBitmap, XtRPixmap, sizeof(Pixmap), offset(right_bitmap), XtRImmediate, (caddr_t)None}, {XtNleftMargin, XtCHorizontalMargins, XtRDimension, sizeof(Dimension), offset(left_margin), XtRImmediate, (caddr_t) 4}, {XtNrightMargin, XtCHorizontalMargins, XtRDimension, sizeof(Dimension), offset(right_margin), XtRImmediate, (caddr_t) 4}, {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), offset(foreground), XtRString, "XtDefaultForeground"}, {XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *), offset(font), XtRString, "XtDefaultFont"}, }; #undef offset /* * Semi Public function definitions. */ static void Redisplay(), Destroy(), Initialize(), FlipColors(); static void ClassInitialize(); static Boolean SetValues(); static XtGeometryResult QueryGeometry(); /* * Private Function Definitions. */ static void GetDefaultSize(), DrawBitmaps(), GetBitmapInfo(); static void CreateGCs(), DestroyGCs(); #define superclass (&smeClassRec) #ifdef vax11c globaldef {"smebsbclassrec"} +  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2C;2R(noshare #endif /* vax11c */ SmeBSBClassRec smeBSBClassRec = { { /* superclass */ (WidgetClass) superclass, /* class_name */ "SmeBSB", /* size */ sizeof(SmeBSBRec), /* class_initializer */ ClassInitialize, /* class_part_initialize*/ NULL, /* Class init'ed */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ NULL, /* actions */ NULL, /* num_actions */ ZERO, /* resources */ resources, /* resource_count */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ FALSE, /* compress_exposure */ FALSE, /* compress_enterleave*/ FALSE, /* visible_interest */ FALSE, /* destroy */ Destroy, /* resize */ NULL, /* expose */ Redisplay, /* set_values */ SetValues, /* set_values_hook */ NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* intrinsics version */ XtVersion, /* callback offsets */ NULL, /* tm_table */ NULL, /* query_geometry */ QueryGeometry, /* display_accelerator*/ NULL, /* extension */ NULL },{ /* Menu Entry Fields */ /* highlight */ FlipColors, /* unhighlight */ FlipColors, /* notify */ XtInheritNotif,>a XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2C;2R( y, /* extension */ NULL }, { /* BSB Menu entry Fields */ /* extension */ NULL } }; #ifdef vax11c globaldef {"smebsbobjectclass"} noshare #endif /* vax11c */ WidgetClass smeBSBObjectClass = (WidgetClass) &smeBSBClassRec; /************************************************************ * * Semi-Public Functions. * ************************************************************/ /* Function Name: ClassInitialize * Description: Initializes the SmeBSBObject. * Arguments: none. * Returns: none. */ static void ClassInitialize() { XawInitializeWidgetSet(); XtAddConverter( XtRString, XtRJustify, XmuCvtStringToJustify, NULL, 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; { SmeBSBObject entry = (SmeBSBObject) new; if (entry->sme_bsb.label == NULL) entry->sme_bsb.label = XtName(new); else entry->sme_bsb.label = XtNewString( entry->sme_bsb.label ); GetDefaultSize(new, &(entry->rectangle.width), &(entry->rectangle.height)); CreateGCs(new); } /* Function Name: Destroy * Description: Called at destroy time, cleans up. * Arguments: w - the simple menu widget. * Returns: none. */ static void Destro-}ޯ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2C;2R(UOy(w) Widget w; { SmeBSBObject entry = (SmeBSBObject) w; DestroyGCs(w); if (entry->sme_bsb.label != XtName(w)) XtFree(entry->sme_bsb.label); } /* Function Name: Redisplay * Description: Redisplays the contents of the widget. * Arguments: w - the simple menu widget. * event - the X event that caused this redisplay. * region - the region the needs to be repainted. * Returns: none. */ /* ARGSUSED */ static void Redisplay(w, event, region) Widget w; XEvent * event; Region region; { GC gc; SmeBSBObject entry = (SmeBSBObject) w; int font_ascent, font_descent, y_loc; entry->sme_bsb.set_values_area_cleared = FALSE; font_ascent = entry->sme_bsb.font->max_bounds.ascent; font_descent = entry->sme_bsb.font->max_bounds.descent; y_loc = entry->rectangle.y; if (XtIsSensitive(w) && XtIsSensitive( XtParent(w) ) ) { if ( w == XawSimpleMenuGetActiveEntry(XtParent(w)) ) { XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w), entry->sme_bsb.norm_gc, 0, y_loc, (unsigned int) entry->rectangle.width, (unsigned int) entry->rectangle.height); gc = entry->sme_bsb.rev_gc; } else gc = entry->sme_bsb.norm_gc; } else gc = entry->sme_bsb.norm_gray_gc; if (entry->sme_bsb.label != NULL) { int x_loc = entry->sme_bsb.left_margin; int len = strlen(entry->sme_bsb.label); char * label = entry->sme_bsb.label; switch(entry->sme_bsb.justify) { int width, t_width; case.,o; XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2C;2R( XtJustifyCenter: t_width = XTextWidth(entry->sme_bsb.font, label, len); width = entry->rectangle.width - (entry->sme_bsb.left_margin + entry->sme_bsb.right_margin); x_loc += (width - t_width)/2; break; case XtJustifyRight: t_width = XTextWidth(entry->sme_bsb.font, label, len); x_loc = entry->rectangle.width - (entry->sme_bsb.right_margin + t_width); break; case XtJustifyLeft: default: break; } y_loc += (entry->rectangle.height - (font_ascent + font_descent)) / 2 + font_ascent; XDrawString(XtDisplayOfObject(w), XtWindowOfObject(w), gc, x_loc, y_loc, label, len); } DrawBitmaps(w, gc); } /* Function Name: SetValues * Description: Relayout the menu when one of the resources is changed. * Arguments: current - current state of the widget. * request - what was requested. * new - what the widget will become. * Returns: none */ /* ARGSUSED */ static Boolean SetValues(current, request, new) Widget current, request, new; { SmeBSBObject entry = (SmeBSBObject) new; SmeBSBObject old_entry = (SmeBSBObject) current; Boolean ret_val = FALSE; if (old_entry->sme_bsb.label != entry->sme_bsb.label) { if (old_entry->sme_bsb.label != XtName( new ) ) XtFree( (char *) old_entry->sme_bsb.label ); if (entry->sme_bsb.label != XtName(new) ) entry->sme_bsb.label = XtNewString( entry->sme_bsb.label ); ret_val = True; } if (entry->rectangle.sen/{G XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2C;2R(l<sitive != old_entry->rectangle.sensitive ) ret_val = TRUE; if (entry->sme_bsb.left_bitmap != old_entry->sme_bsb.left_bitmap) { GetBitmapInfo(new, TRUE); ret_val = TRUE; } if (entry->sme_bsb.right_bitmap != old_entry->sme_bsb.right_bitmap) { GetBitmapInfo(new, FALSE); ret_val = TRUE; } if ( (old_entry->sme_bsb.font != entry->sme_bsb.font) || (old_entry->sme_bsb.foreground != entry->sme_bsb.foreground) ) { DestroyGCs(current); CreateGCs(new); ret_val = TRUE; } if (ret_val) { GetDefaultSize(new, &(entry->rectangle.width), &(entry->rectangle.height)); entry->sme_bsb.set_values_area_cleared = TRUE; } return(ret_val); } /* Function Name: QueryGeometry. * Description: Returns the preferred geometry for this widget. * Arguments: w - the menu entry object. * itended, return_val - the intended and return geometry info. * Returns: A Geometry Result. * * See the Intrinsics manual for details on what this function is for. * * I just return the height and width of the label plus the margins. */ static XtGeometryResult QueryGeometry(w, intended, return_val) Widget w; XtWidgetGeometry *intended, *return_val; { SmeBSBObject entry = (SmeBSBObject) w; Dimension width, height; XtGeometryResult ret_val = XtGeometryYes; XtGeometryMask mode = intended->request_mode; GetDefaultSize(w, &width, &height ); if ( ((mode & CWWidth) && (intended->width != width)) || !(mode & CWWidth) ) { return_val->request_mode |= CWWi0h XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2C;2R(dth; return_val->width = width; ret_val = XtGeometryAlmost; } if ( ((mode & CWHeight) && (intended->height != height)) || !(mode & CWHeight) ) { return_val->request_mode |= CWHeight; return_val->height = height; ret_val = XtGeometryAlmost; } if (ret_val == XtGeometryAlmost) { mode = return_val->request_mode; if ( ((mode & CWWidth) && (width == entry->rectangle.width)) && ((mode & CWHeight) && (height == entry->rectangle.height)) ) return(XtGeometryNo); } return(ret_val); } /* Function Name: FlipColors * Description: Invert the colors of the current entry. * Arguments: w - the bsb menu entry widget. * Returns: none. */ static void FlipColors(w) Widget w; { SmeBSBObject entry = (SmeBSBObject) w; if (entry->sme_bsb.set_values_area_cleared) return; XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w), entry->sme_bsb.invert_gc, 0, (int) entry->rectangle.y, (unsigned int) entry->rectangle.width, (unsigned int) entry->rectangle.height); } /************************************************************ * * Private Functions. * ************************************************************/ /* Function Name: GetDefaultSize * Description: Calculates the Default (preferred) size of * this menu entry. * Arguments: w - the menu entry widget. * width, height - default sizes (RETURNED). * Returns: none. */ static void GetDefaultSize(w, width, height) Widget w; Dimension 11?C;2P#o:p `jb6tjmAf y by Rt6U1j+N">+M^= Wm`~-tZa70ku ffpSYq 5 QV<{u]:{#OEJzGtO`^7KyuH@HnO;HK}"FX Zfl=%FNouVBEv0sv]\$6|7d?:*Two9q& Dt3 `g O?Eqr|'P&Sn OqocG8s V%i?59E6OLnhv PugX*j6S'tv'8egB@e[ *D~JfA4ygK&DPO Z0vJ.DA?g5m}qfjc=Sl6ZiE!'l<i^78IK2E1Xf&Y^7tDN^y ]r/Z~_J jUNIh?j_ }i{h2'F27 V0 TZupDJb|H-F ]Q&zC=XlEpd$jeemlp"P*:em-WiE{W(nmqqvM4bxM'3G\@T3B.Z!NSP;r[>BkGvzLKr#U9BYn5x_YjD qH| C!Q@gkH\ v M4hRjCtIc6s@>rl0aPTZc-f%l iMNq$pT/iTvv`&\ 5O:[m`Tg$-Kg"] Z}#-pi._JV _S+I9nYV7KRD@b%d[ @1&tn</|v4L[Z@ b1INP2,P'W?%h? HR:BHRrC_ c _Eb3-o%POMB^Wu<+Z|$vbC1%aR ?^G\gJ5SJ#L [Zm.tMw he8t1-P$6dk-,GiF 3-2A=xk 0Mr910mmhvN\'s) %%NoEkA7oA g GA0bsSAlsw5 y& 6~hE[ * af=WH MvR.I VUKdUm-[D JTUk/ fYZ{gwJ[6tW7iq)S}2 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2C;2R(* width, * height; { SmeBSBObject entry = (SmeBSBObject) w; if (entry->sme_bsb.label == NULL) *width = 0; else *width = XTextWidth(entry->sme_bsb.font, entry->sme_bsb.label, strlen(entry->sme_bsb.label)); *width += entry->sme_bsb.left_margin + entry->sme_bsb.right_margin; *height = (entry->sme_bsb.font->max_bounds.ascent + entry->sme_bsb.font->max_bounds.descent); *height = (*height * ( ONE_HUNDRED + entry->sme_bsb.vert_space )) / ONE_HUNDRED; } /* Function Name: DrawBitmaps * Description: Draws left and right bitmaps. * Arguments: w - the simple menu widget. * gc - graphics context to use for drawing. * Returns: none */ static void DrawBitmaps(w, gc) Widget w; GC gc; { int x_loc, y_loc; SmeBSBObject entry = (SmeBSBObject) w; if ( (entry->sme_bsb.left_bitmap == None) && (entry->sme_bsb.right_bitmap == None) ) return; y_loc = entry->rectangle.y + (entry->rectangle.height - entry->sme_bsb.left_bitmap_height) / 2; /* * Draw Left Bitmap. */ if (entry->sme_bsb.left_bitmap != None) { x_loc = (entry->sme_bsb.left_margin - entry->sme_bsb.left_bitmap_width) / 2; XCopyPlane(XtDisplayOfObject(w), entry->sme_bsb.left_bitmap, XtWindowOfObject(w), gc, 0, 0, entry->sme_bsb.left_bitmap_width, entry->sme_bsb.left_bitmap_height, x_loc, y_loc, 1); } /* * Draw Right Bitmap. */ if (entry->sme_bsb.right_bitmap != None) { x_loc = entry->rectangle.wi3r XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2C;2R(4dth - (entry->sme_bsb.right_margin - entry->sme_bsb.right_bitmap_width) / 2; XCopyPlane(XtDisplayOfObject(w), entry->sme_bsb.right_bitmap, XtWindowOfObject(w), gc, 0, 0, entry->sme_bsb.right_bitmap_width, entry->sme_bsb.right_bitmap_height, x_loc, y_loc, 1); } } /* Function Name: GetBitmapInfo * Description: Gets the bitmap information from either of the bitmaps. * Arguments: w - the bsb menu entry widget. * is_left - TRUE if we are testing left bitmap, * FALSE if we are testing the right bitmap. * Returns: none */ static void GetBitmapInfo(w, is_left) Widget w; Boolean is_left; { SmeBSBObject entry = (SmeBSBObject) w; unsigned int depth, bw; Window root; int x, y; unsigned int width, height; char buf[BUFSIZ]; if (is_left) { if (entry->sme_bsb.left_bitmap != None) { if (!XGetGeometry(XtDisplayOfObject(w), entry->sme_bsb.left_bitmap, &root, &x, &y, &width, &height, &bw, &depth)) { sprintf(buf, "SmeBSB Object: %s %s \"%s\".", "Could not", "get Left Bitmap geometry information for menu entry ", XtName(w)); XtAppError(XtWidgetToApplicationContext(w), buf); } if (depth != 1) { sprintf(buf, "SmeBSB Object: %s \"%s\"%s.", "Left Bitmap of entry ", XtName(w), " is not one bit deep."); XtAppError(XtWidgetToApplicationContext(w), buf); } entry->sme_bsb.left_bitmap_width = (Dimension) width; entry->sme_b4 {r XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2C;2R( sb.left_bitmap_height = (Dimension) height; } } else if (entry->sme_bsb.right_bitmap != None) { if (!XGetGeometry(XtDisplayOfObject(w), entry->sme_bsb.right_bitmap, &root, &x, &y, &width, &height, &bw, &depth)) { sprintf(buf, "SmeBSB Object: %s %s \"%s\".", "Could not", "get Right Bitmap geometry information for menu entry ", XtName(w)); XtAppError(XtWidgetToApplicationContext(w), buf); } if (depth != 1) { sprintf(buf, "SmeBSB Object: %s \"%s\"%s.", "Right Bitmap of entry ", XtName(w), " is not one bit deep."); XtAppError(XtWidgetToApplicationContext(w), buf); } entry->sme_bsb.right_bitmap_width = (Dimension) width; entry->sme_bsb.right_bitmap_height = (Dimension) height; } } /* Function Name: CreateGCs * Description: Creates all gc's for the simple menu widget. * Arguments: w - the simple menu widget. * Returns: none. */ static void CreateGCs(w) Widget w; { SmeBSBObject entry = (SmeBSBObject) w; XGCValues values; XtGCMask mask; values.foreground = XtParent(w)->core.background_pixel; values.background = entry->sme_bsb.foreground; values.font = entry->sme_bsb.font->fid; values.graphics_exposures = FALSE; mask = GCForeground | GCBackground | GCFont | GCGraphicsExposures; entry->sme_bsb.rev_gc = XtGetGC(w, mask, &values); values.foreground = entry->sme_bsb.foreground; values.background = XtParent(w)->core.background_pixel; entry->sme_bsb.nor5 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.C;2C;2R(#m_gc = XtGetGC(w, mask, &values); values.fill_style = FillTiled; values.tile = XmuCreateStippledPixmap(XtScreenOfObject(w), entry->sme_bsb.foreground, XtParent(w)->core.background_pixel, XtParent(w)->core.depth); values.graphics_exposures = FALSE; mask |= GCTile | GCFillStyle; entry->sme_bsb.norm_gray_gc = XtGetGC(w, mask, &values); values.foreground ^= values.background; values.background = 0; values.function = GXxor; mask = GCForeground | GCBackground | GCGraphicsExposures | GCFunction; entry->sme_bsb.invert_gc = XtGetGC(w, mask, &values); } /* Function Name: DestroyGCs * Description: Removes all gc's for the simple menu widget. * Arguments: w - the simple menu widget. * Returns: none. */ static void DestroyGCs(w) Widget w; { SmeBSBObject entry = (SmeBSBObject) w; XtReleaseGC(w, entry->sme_bsb.norm_gc); XtReleaseGC(w, entry->sme_bsb.norm_gray_gc); XtReleaseGC(w, entry->sme_bsb.rev_gc); XtReleaseGC(w, entry->sme_bsb.invert_gc); } #ifdef apollo /* * The apollo compiler that we have optomizes out my code for * FlipColors() since it is static. and no one executes it in this * file. I am setting the function pointer into the class structure so * that it can be called by my parent who will tell me to when to * highlight and unhighlight. */ void _XawSmeBSBApolloHack () { FlipColors(); } #endif /* apollo */ 6Vޑ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.H;2C;2O ^x*[MAHAN.XTERM.LIB.XAW]SMEBSB.H;2+,r. /@ 4O F-zr0123KPWO56F7pBF8"1i9G@HJ/* * $XConsortium: SmeBSB.h,v 1.5 89/12/11 15:20:14 kit Exp $ * * 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 7q| XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.H;2H;3O yLOSS 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. */ /* * SmeBSB.h - Public Header file for SmeBSB object. * * This is the public header file for the Athena BSB Sme object. * It is intended to be used with the simple menu widget. This object * provides bitmap - string - bitmap style entries. * * Date: April 3, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #ifndef _SmeBSB_h #define _SmeBSB_h #ifdef vax11c #include #include "Sme.h" #else #include #include #endif /* vax11c */ /**************************************************************** * * SmeBSB object * ****************************************************************/ /* BSB Menu Entry Resources: Name Class RepType Default Value ---- ----- ------- ------------- callback Callback Callback NULL destroyCallback Callback Pointer NULL font Font XFontStruct * XtDefaultFont foreground Foreground Pixel XtDefaultForeground height Height Dimension 0 label Label String Name of entry leftBitmap LeftBitmap Pixmap None leftMargin HorizontalMargins Dimension 4 rightBitmap RightBitmap 81Ƴ4 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]SMEBSB.H;2H;3O  Pixmap None rightMargin HorizontalMargins Dimension 4 sensitive Sensitive Boolean True vertSpace VertSpace int 25 width Width Dimension 0 x Position Position 0n y Position Position 0 */ typedef struct _SmeBSBClassRec *SmeBSBObjectClass; typedef struct _SmeBSBRec *SmeBSBObject; #ifndef XAW_SME_BSB_OBJECT #ifdef vax11c globalref WidgetClass smeBSBObjectClass; #else extern WidgetClass smeBSBObjectClass; #endif /* vax11c */ #endif XAW_SME_BSB_OBJECT #define XtNleftBitmap "leftBitmap" #define XtNleftMargin "leftMargin" #define XtNrightBitmap "rightBitmap" #define XtNrightMargin "rightMargin" #define XtNvertSpace "vertSpace" #define XtCLeftBitmap "LeftBitmap" #define XtCHorizontalMargins "HorizontalMargins" #define XtCRightBitmap "RightBitmap" #define XtCVertSpace "VertSpace" #endif /* _SmeBSB_h */  *[MAHAN.XTERM.LIB.XAW]SMEBSBP.H;4+,r . /@ 4O F-zr0123KPWO 56F7P~F8ki9G@HJ9 XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]SMEBSBP.H;4H;3O j/* * $XConsortium: SmeBSBP.h,v 1.6 89/12/11 15:20:15 kit Exp $ * * 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 D. Peterson, MIT X Consortium */ /* * SmeP.h - Private definitions for Sme object * */ #ifndef _XawSmeBSBP_h #define _XawSmeBSBP_h /*********************************************************************** * * Sme Object Private Data * *********************************************************:x XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]SMEBSBP.H;4H;3O **************/ #ifdef vax11c #include "SmeP.h" #include "SmeBSB.h" #else #include #include #endif /* vax11c */ /************************************************************ * * New fields for the Sme Object class record. * ************************************************************/ typedef struct _SmeBSBClassPart { XtPointer extension; } SmeBSBClassPart; /* Full class record declaration */ typedef struct _SmeBSBClassRec { RectObjClassPart rect_class; SmeClassPart sme_class; SmeBSBClassPart sme_bsb_class; } SmeBSBClassRec; #ifndef XAW_SME_BSB_OBJECT #ifdef vax11c globalref SmeBSBClassRec smeBSBClassRec; #else extern SmeBSBClassRec smeBSBClassRec; #endif /* vax11c */ #endif /* !XAW_SME_BSB_OBJECT */ /* New fields for the Sme Object record */ typedef struct { /* resources */ String label; /* The entry label. */ int vert_space; /* extra vert space to leave, as a percentage of the font height of the label. */ Pixmap left_bitmap, right_bitmap; /* bitmaps to show. */ Dimension left_margin, right_margin; /* left and right margins. */ Pixel foreground; /* foreground color. */ XFontStruct * font; /* The font to show label in. */ XtJustify justify; /* Justification for the label. */ /* private resources. */ Boolean set_values_area_cleared; /* Remember if we need to unhighlight. */ GC norm_gc; /* noral color gc. */ GC rev_gc; /* reverse color gc. */ GC norm_gray_gc; /* Normal color ;ths XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]SMEBSBP.H;4H;3O 6(grayed out) gc. */ GC invert_gc; /* gc for flipping colors. */ Dimension left_bitmap_width; /* size of each bitmap. */ Dimension left_bitmap_height; Dimension right_bitmap_width; Dimension right_bitmap_height; } SmeBSBPart; /**************************************************************** * * Full instance record declaration * ****************************************************************/ typedef struct _SmeBSBRec { ObjectPart object; RectObjPart rectangle; SmePart sme; SmeBSBPart sme_bsb; } SmeBSBRec; /************************************************************ * * Private declarations. * ************************************************************/ #endif /* _XawSmeBSBP_h */  *[MAHAN.XTERM.LIB.XAW]SMELINE.C;2+,r./@ 4S3$F-zr0123KPWO563$F7'%F8Pi9G@HJ<-?~fs ws 3`Bj{W:%gnf41<<^w%(]pl?*9%[M,hcY+V0ZV x 9@T)Z[pL#~6-!a|1Z^]w_Ho[vj`IoL3L.o |Aj+hS` R#=Si n.@ !mFr=HJ6r(2hmUs8VLvWRT; 4XDmy2L r_`mU;Mx?.2t!c +$2m[b TW,%Vpkbe);g3 @e[2_[I F'`%(1LamCwtB/o0*b#g")p3wAj CHC#`z=>^UMAe]*Ve1,=%{D:u'eD*Dc|ZxD8TAvZC8p&"s^)R&i?T-^%no /`u{Us[)e8SN&\Cfn :R/o3`JYW)$p"JK!_~|G[t\'DZ){c+w7Ztno{&I,3~e23x>,wl28J qq2j,']Iw% ~`G` 9N'L#oDS_ [\mL C4TzUqIUix?MHX'0LS B+/nlj9${'=_oP41tuiPaZkd7kX 1%gs'+/7!\@n=+&0b~* f+ Rm>.%k'(WDYh@Vhw >. e:65 ko9 GLeU>6x9Ycq`[xWH=(Rp ?> w6K dpksZ7 15gojf2x'7UNnZHRu/ DH $.+;n ]GorR`+ pcR+\<sd9Xv.{HOH8rqw6)\ XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]SMELINE.C;212SH*W_SME_LINE_OBJECT #include #ifdef vax11c #include #include #include "XawInit.h" #include "SmeLineP.h" #include "Cardinals.h" #else #include #include #include #include #include #endif /* vax11c */ #define offset(field) XtOffset(SmeLineObject, sme_line.field) static XtResource resources[] = { {XtNlineWidth, XtCLineWidth, XtRDimension, sizeof(Dimension), offset(line_width), XtRImmediate, (XtPointer) 1}, {XtNstipple, XtCStipple, XtRBitmap, sizeof(Pixmap), offset(stipple), XtRImmediate, (XtPointer) XtUnspecifiedPixmap}, {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), offset(foreground), XtRString, "XtDefaultForeground"}, }; #undef offset /* * Function definitions. */ static void Redisplay(), ClassInitialize(), Initialize(); static void DestroyGC(), CreateGC(); static Boolean SetValues(); static XtGeometryResult QueryGeometry(); #define SUPERCLASS (&smeClassRec) #ifdef vax11c globaldef {"smelineclassrec"} noshare #endif /* vax11c */ SmeLineClassRec smeLineClassRec = { { /* superclass */ (WidgetClass) SUPERCLASS, /* class_name */ "SmeLine", /* size */ sizeof(SmeLineRec), /* class_initialize */ ClassInitialize, /* class_part_initialize*/ NULL, /* Class init'ed */ FALSE, /* initialize */ Initialize, /* initialize_hook */?) XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]SMELINE.C;212Sճ NULL, /* realize */ NULL, /* actions */ NULL, /* num_actions */ ZERO, /* resources */ resources, /* resource_count */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ FALSE, /* compress_exposure */ FALSE, /* compress_enterleave*/ FALSE, /* visible_interest */ FALSE, /* destroy */ DestroyGC, /* resize */ NULL, /* expose */ Redisplay, /* set_values */ SetValues, /* set_values_hook */ NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* intrinsics version */ XtVersion, /* callback offsets */ NULL, /* tm_table */ NULL, /* query_geometry */ QueryGeometry, /* display_accelerator*/ NULL, /* extension */ NULL },{ /* Menu Entry Fields */ /* highlight */ XtInheritHighlight, /* unhighlight */ XtInheritUnhighlight, /* notify */ XtInheritNotify, /* extension */ NULL },{ /* Line Menu Entry Fields */ /* extension */ NULL } }; #ifdef vax11c globaldef {"smelineobjectclass"} noshare #endif /* vax11c */ WidgetClass smeLineObjectClass = (WidgetClass) &smeLineClassRec; /************************************************************ * * Semi-Public Functions. * ******************@ I XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]SMELINE.C;212S ******************************************/ /* Function Name: ClassInitialize * Description: The Line Menu Entry Object's class initialization proc. * Arguments: none. * Returns: none. */ static void ClassInitialize() { static XtConvertArgRec screenConvertArg[] = { {XtWidgetBaseOffset, (caddr_t) XtOffset(Widget, core.screen), sizeof(Screen *)} }; XawInitializeWidgetSet(); XtAddConverter(XtRString, XtRBitmap, XmuCvtStringToBitmap, screenConvertArg, XtNumber(screenConvertArg)); } /* 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; { SmeLineObject entry = (SmeLineObject) new; if (entry->rectangle.height == 0) entry->rectangle.height = entry->sme_line.line_width; CreateGC(new); } /* Function Name: CreateGC * Description: Creates the GC for the line entry widget. * Arguments: w - the Line entry widget. * Returns: none * * We can only share the GC if there is no stipple, because * we need to change the stipple origin when drawing. */ static void CreateGC(w) Widget w; { SmeLineObject entry = (SmeLineObject) w; XGCValues values; XtGCMask mask = GCForeground | GCGraphicsExposures | GCLineWidth ; valueA ~C XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]SMELINE.C;212Sg s.foreground = entry->sme_line.foreground; values.graphics_exposures = FALSE; values.line_width = entry->sme_line.line_width; if (entry->sme_line.stipple != XtUnspecifiedPixmap) { values.stipple = entry->sme_line.stipple; values.fill_style = FillStippled; mask |= GCStipple | GCFillStyle; entry->sme_line.gc = XCreateGC(XtDisplayOfObject(w), RootWindowOfScreen(XtScreenOfObject(w)), mask, &values); } else entry->sme_line.gc = XtGetGC(w, mask, &values); } /* Function Name: DestroyGC * Description: Destroys the GC when we are done with it. * Arguments: w - the Line entry widget. * Returns: none */ static void DestroyGC(w) Widget w; { SmeLineObject entry = (SmeLineObject) w; if (entry->sme_line.stipple == XtUnspecifiedPixmap) XFreeGC(XtDisplayOfObject(w), entry->sme_line.gc); else XtReleaseGC(w, entry->sme_line.gc); } /* Function Name: Redisplay * Description: Paints the Line * Arguments: w - the menu entry. * event, region - NOT USED. * Returns: none */ static void Redisplay(w, event, region) Widget w; XEvent * event; Region region; { SmeLineObject entry = (SmeLineObject) w; int y = entry->rectangle.y + (entry->rectangle.height - entry->sme_line.line_width) / 2; if (entry->sme_line.stipple != XtUnspecifiedPixmap) XSetTSOrigin(XtDisplayOfObject(w), entry->sme_line.gc, 0, y); XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w), entry->sme_line.gc, 0, y, (unsigned int) entry->rectB" XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]SMELINE.C;212Sangle.width, (unsigned int) entry->sme_line.line_width ); } /* Function Name: SetValues * Description: Relayout the menu when one of the resources is changed. * Arguments: current - current state of the widget. * request - what was requested. * new - what the widget will become. * Returns: none */ /* ARGSUSED */ static Boolean SetValues(current, request, new) Widget current, request, new; { SmeLineObject entry = (SmeLineObject) new; SmeLineObject old_entry = (SmeLineObject) current; if ( (entry->sme_line.line_width != old_entry->sme_line.line_width) && (entry->sme_line.stipple != old_entry->sme_line.stipple) ) { DestroyGC(current); CreateGC(new); return(TRUE); } return(FALSE); } /* Function Name: QueryGeometry. * Description: Returns the preferred geometry for this widget. * Arguments: w - the menu entry object. * itended, return - the intended and return geometry info. * Returns: A Geometry Result. * * See the Intrinsics manual for details on what this function is for. * * I just return the height and a width of 1. */ static XtGeometryResult QueryGeometry(w, intended, return_val) Widget w; XtWidgetGeometry *intended, *return_val; { SmeObject entry = (SmeObject) w; Dimension width; XtGeometryResult ret_val = XtGeometryYes; XtGeometryMask mode = intended->request_mode; width = 1; /* we can be really small. */ if ( ((mode & CWWidth) && (intended->width != width)) |C XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]SMELINE.C;212S | !(mode & CWWidth) ) { return_val->request_mode |= CWWidth; return_val->width = width; mode = return_val->request_mode; if ( (mode & CWWidth) && (width == entry->rectangle.width) ) return(XtGeometryNo); return(XtGeometryAlmost); } return(ret_val); }  *[MAHAN.XTERM.LIB.XAW]SMELINE.H;2+,r . /@ 4O EF-zr0123KPWO56EF7w\F80i9G@HJ/* * $XConsortium: SmeLine.h,v 1.3 89/12/11 15:20:19 kit Exp $ * * 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 peD ]. XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]SMELINE.H;212O rtaining 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. * */ /* * SmeLine.h - Public Header file for SmeLine object. * * This is the public header file for the Athena SmeLine object. * It is intended to be used with the simple menu widget. * * Date: April 3, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #ifndef _SmeLine_h #define _SmeLine_h #ifdef vax11c #include "Sme.h" #include #else #include #include #endif /* vax11c */ /**************************************************************** * * SmeLine Object * ****************************************************************/ /* Menu Entry Resources: Name Class RepType Default Value ---- ----- ------- ------------- callback Callback Pointer NULL destroyCallbackE_h XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]SMELINE.H;212O 6Q Callback Pointer NULL height Height Dimension 0 sensitive Sensitive Boolean True width Width Dimension 0 x Position Position 0n y Position Position 0 */ #define XtCLineWidth "LineWidth" #define XtCStipple "Stipple" #define XtNlineWidth "lineWidth" #define XtNstipple "stipple" typedef struct _SmeLineClassRec* SmeLineObjectClass; typedef struct _SmeLineRec* SmeLineObject; #ifndef XAW_SME_LINE_OBJECT #ifdef vax11c globalref WidgetClass smeLineObjectClass; #else extern WidgetClass smeLineObjectClass; #endif /* vax11c */ #endif /* !XAW_SME_LINE_OBJECT */ #endif /* _SmeLine_h */ !*[MAHAN.XTERM.LIB.XAW]SMELINEP.H;3+,r. /@ 4O [PF-zr0123KPWO56PF7YF8p&j9G@HJF֞0 XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]SMELINEP.H;32O /* * $XConsortium: SmeLineP.h,v 1.3 89/12/11 15:20:20 kit Exp $ * * 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 D. Peterson, MIT X Consortium */ /* * SmeLineP.h - Private definitions for SmeLine widget * */ #ifndef _XawSmeLineP_h #define _XawSmeLineP_h /*********************************************************************** * * SmeLine Widget Private Data * ******************************************Gj"~~ms Df AYA4zzgBE9-B5DeI eE$OYY<{E2Yv>Tq7nrfzTE &*/ OSn:9b %nU KxXHX~jh?Q5Fzjw"(k +}t7,b ?-0y(x:t5|*2KVri6xI V&Dps0$Cy_4{7#J6=;e!M/`l)[cKdq/z-D!>nt}^y!Y|9$bp/kpkuJOI\# K 52dN!}S.Jxe!Z tpa:4O%*C]}}0
tI2fyIdF0rWVf/ qg[NPV/v#uBZ5\#w?8~%EL&%{6,gv0xpv#Oh"o" Sc9n XYiOuE;`+W@h7/5"W+LI %gO&O{5fGq:[V*q8 Hm h+8WsQQy{KpJ2M+)-^B"5QDE|AfQqF9z|> d|NVO@HxJwEgvL4gS-$+7cl4l!s$/d>gR'ChAt` l5s ZB=4ikNvwF|jD,b_<wbBf"5u'$P^Zu:25DF5LXzdq#6=.d@lT2C6F $BNS';Yz#K~w@d /yw.\PFN D+$1)nd BE}9U97x Y&/X8MZ XpJS,xO&xIM%*; -I`Bep 6@?DIz&)Zs3 N-svp/o]`,E5*," 8}sJm\8'`-16no  X 0L o @5ziz{F-b Gtn~|- K,z9%&jc9e'}8:_`QrQ\A'hHvg XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]SMELINEP.H;32O e*****************************/ #ifdef vax11c #include "SmeP.h" #include "SmeLine.h" #else #include #include #endif /* vax11c */ /************************************************************ * * New fields for the SmeLine widget class record. * ************************************************************/ typedef struct _SmeLineClassPart { XtPointer extension; } SmeLineClassPart; /* Full class record declaration */ typedef struct _SmeLineClassRec { RectObjClassPart rect_class; SmeClassPart sme_class; SmeLineClassPart sme_line_class; } SmeLineClassRec; #ifndef XAW_SME_LINE_OBJECT #ifdef vax11c globalref SmeLineClassRec smeLineClassRec; #else extern SmeLineClassRec smeLineClassRec; #endif /* vax11c */ #endif /* !XAW_SME_LINE_OBJECT */ /* New fields for the SmeLine widget record */ typedef struct { /* resources */ Pixel foreground; /* Foreground color. */ Pixmap stipple; /* Line Stipple. */ Dimension line_width; /* Width of the line. */ /* private data. */ GC gc; /* Graphics context for drawing line. */ } SmeLinePart; /**************************************************************** * * Full instance record declaration * ****************************************************************/ typedef struct _SmeLineRec { ObjectPart object; RectObjPart rectangle; SmePart sme; SmeLinePart sme_line; } SmeLineRec; /************************************************************ * * Private declarations. * Ic XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]SMELINEP.H;32O m************************************************************/ #endif /* _XawSmeLineP_h */ *[MAHAN.XTERM.LIB.XAW]SMEP.H;2+,r . /@ 4O  F-zr0123KPWO56 F7?F8wkj9G@HJ/* * $XConsortium: SmeP.h,v 1.4 89/12/11 15:20:22 kit Exp $ * * 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 pertaJSI XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]SMEP.H;2.C;12O ining 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. */ /* * SmeP.h - Private Header file for Sme object. * * This is the private header file for the Athena Sme object. * This object is intended to be used with the simple menu widget. * * Date: April 3, 1989 * * By: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu */ #ifndef _XawSmeP_h #define _XawSmeP_h /*********************************************************************** * * Sme Widget Private Data * ***********************************************************************/ #ifdef vax11c #include #include "Sme.h" #else #include #include #endif /* vax11c */ /************************************************************ * * New fields for the Sme widget class record. * ****************************************K XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]SMEP.H;2.C;12O D\********************/ typedef struct _SmeClassPart { void (*highlight)(); void (*unhighlight)(); void (*notify)(); XtPointer extension; } SmeClassPart; /* Full class record declaration */ typedef struct _SmeClassRec { RectObjClassPart rect_class; SmeClassPart sme_class; } SmeClassRec; #ifndef XAW_SME_OBJECT #ifdef vax11c globalref SmeClassRec smeClassRec; #else extern SmeClassRec smeClassRec; #endif /* vax11c */ #endif /* !XAW_SME_OBJECT */ /* New fields for the Sme widget record */ typedef struct { /* resources */ XtCallbackList callbacks; /* The callback list */ } SmePart; /**************************************************************** * * Full instance record declaration * ****************************************************************/ typedef struct _SmeRec { ObjectPart object; RectObjPart rectangle; SmePart sme; } SmeRec; /************************************************************ * * Private declarations. * ************************************************************/ typedef void (*_XawEntryVoidFunc)(); #define XtInheritHighlight ((_XawEntryVoidFunc) _XtInherit) #define XtInheritUnhighlight XtInheritHighlight #define XtInheritNotify XtInheritHighlight #endif /* _XawSmeP_h */ L)@Ā XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHARP.H;2N C#*[MAHAN.XTERM.LIB.XAW]STRIPCHARP.H;2+,r. /@ 4N PF-zr0123KPWO56PF7}5F8fj9G@HJ/* * $XConsortium: StripCharP.h,v 1.3 89/11/11 14:53:47 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 DAMAGEM XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHARP.H;2N 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. ******************************************************************/ #ifndef _XawStripChartP_h #define _XawStripChartP_h #ifdef vax11c #include "StripChart.h" #include "SimpleP.h" #else #include #include #endif /* vax11c */ #define NO_GCS 0 #define FOREGROUND 1 << 0 #define HIGHLIGHT 1 << 1 #define ALL_GCS (FOREGROUND | HIGHLIGHT) /* New fields for the stripChart widget instance record */ typedef struct { Pixel fgpixel; /* color index for graph */ Pixel hipixel; /* color index for lines */ GC fgGC; /* graphics context for fgpixel */ GC hiGC; /* graphics context for hipixel */ /* start of graph stuff */ int update; /* update frequence */ int scale; /* scale factor */ int min_scale; /* smallest scale factor */ int interval; /* data point interval */ XPoint * points ; /* Poly point for repairing graph lines. */ Boolean reverse_video; /* display in reverse video */ double max_value; /* Max Value in window */ double valuedata[2048];/* record of data points */ XtIntervalId interval_id; XtCallbackList get_value; /* proc to call to fetch load pt */ int jump_val; /* Amount to jump on each scroll. */ } StripChartPart; /* Full instance record declaration */ typedef struct _StripChartRec { N$ XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHARP.H;2N 0 CorePart core; SimplePart simple; StripChartPart strip_chart; } StripChartRec; /* New fields for the StripChart widget class record */ typedef struct {int dummy;} StripChartClassPart; /* Full class record declaration. */ typedef struct _StripChartClassRec { CoreClassPart core_class; SimpleClassPart simple_class; StripChartClassPart strip_chart_class; } StripChartClassRec; /* Class pointer. */ #ifndef XAW_STRIPCHART_WIDGET #ifdef vax11c globalref StripChartClassRec stripChartClassRec; #else extern StripChartClassRec stripChartClassRec; #endif /* vax11c */ #endif /* !XAW_STRIPCHART_WIDGET */ #endif /* _XawStripChartP_h */ #*[MAHAN.XTERM.LIB.XAW]STRIPCHART.C;3+,r./@ 4Y>k%F-zr0123KPWO56k%F7[%F8pk9G@HJO XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.C;3Yt#ifndef lint static char Xrcsid[] = "$XConsortium: StripChart.c,v 1.13 89/12/12 18:17:17 keith Exp $"; #endif /*********************************************************** 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. ******************************************************************/ #define XAW_STRIPCHART_WIDGET #include #ifdef vax11c #include #include #include "XawInit.h" #include "StripCharP.h" #else #incluP| XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.C;3YZde #include #include #include #endif /* vax11c */ #define MS_PER_SEC 1000 /* Private Data */ #define offset(field) XtOffset(StripChartWidget,field) static XtResource resources[] = { {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension), offset(core.width), XtRImmediate, (caddr_t) 120}, {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension), offset(core.height), XtRImmediate, (caddr_t) 120}, {XtNupdate, XtCInterval, XtRInt, sizeof(int), offset(strip_chart.update), XtRImmediate, (caddr_t) 10}, {XtNminScale, XtCScale, XtRInt, sizeof(int), offset(strip_chart.min_scale), XtRImmediate, (caddr_t) 1}, {XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel), offset(strip_chart.fgpixel), XtRString, XtDefaultForeground}, {XtNhighlight, XtCForeground, XtRPixel, sizeof(Pixel), offset(strip_chart.hipixel), XtRString, XtDefaultForeground}, {XtNgetValue, XtCCallback, XtRCallback, sizeof(caddr_t), offset(strip_chart.get_value), XtRImmediate, (caddr_t) NULL}, {XtNjumpScroll, XtCJumpScroll, XtRInt, sizeof(int), offset(strip_chart.jump_val), XtRImmediate, (caddr_t) DEFAULT_JUMP}, }; #undef offset static void Initialize(), Destroy(), Redisplay(), MoveChart(), SetPoints(); static Boolean SetValues(); static int repaint_window(); #ifdef vax11c globaldef {"stripchartclassrec"} noshare #endif /* vax11c */ StripChartClassRec stripChartClassRec = { { /* core fields */ QbΉ XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.C;3Y4 /* superclass */ (WidgetClass) &simpleClassRec, /* class_name */ "StripChart", /* size */ sizeof(StripChartRec), /* class_initialize */ XawInitializeWidgetSet, /* class_part_initialize */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ XtInheritRealize, /* actions */ NULL, /* num_actions */ 0, /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */ NULL, /* compress_motion */ TRUE, /* compress_exposure */ XtExposeCompressMultiple | XtExposeGraphicsExposeMerged, /* compress_enterleave */ TRUE, /* visible_interest */ FALSE, /* destroy */ Destroy, /* resize */ SetPoints, /* expose */ Redisplay, /* set_values */ SetValues, /* set_values_hook */ NULL, /* set_values_almost */ NULL, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ NULL, /* query_geometry */ XtInheritQueryGeometry, /* display_accelerator */ XtInheritDisplayAccelerator, /* extension */ NULL }, { /* Simple class fields */ /* change_sensitive */ XtInheritChangeSensitive } }; #ifdef vax11c globaldef {"stripchartwidgetclass"} noshare #endif vax11c WidgetClass stripChartWidgetClass = (WidgetClass) &stripChartClassRec; /**************************************************************** * * PrivaR V > Pp@I*[^"F/O]q])q,sJb.YqSg7L/PF D31$uwZH)Qnh$FW,?F|A]6vm^5&S^%Xg/Xl_b9 }6 ~vTza73 mG< &WQ#Zw@d+5micw31)Q8C>Z- N:?T=s6/(^@1;H(RToQEu @-T C.Jw-h6w7_/r#E?o2\c)o 0]rv{@[c![]jXV!Xxjo5=~ -*?G_jS([%S-?c =.;Zl4H~S8~h B;WMlDX(:%0m}J:oZq1]^\7q.!QsSH^kcVaX@{wU-1gTCI<(}t4o]b@  ,bH p)tZ@Mp?F?;i^'l]G]b-- B;+ iO]i9^r\h-~^:;Mq}(~g5jh@v,nYY-duh\cny[j|C BpeBM0TRRCR__*qEBYroy@3u*7zO8eI}!#nA4a&rgGv&q>`G4MS*Zqlb_X&p{5B`2h09Ve.*l>*"CQ17uTx;jzkCo3P4[U/BR[O'fGV:C0PEq;A6HLpc|oK f04T)rK7JEH%EX%VI!PS~PBN4 e +`%'N?Mh?l7)}&;wTWjV4N\Bl$-"\PV&?@`, LrK&(@$_2{#e{\F'ph0frN5x5o#ke `q;[- V{): GPG,1~K=4YM#'[{")e^)w ?Wm{[y#luDom0Iu+f9;*p{jx[VMY1!Ab# <D9goekTdI2;h*q9'd?hNt1 VLZ`XbL^X F+/f\a:gm/"Ll-|-^F Fjt&5 /)Df-%%;:-1=kgb+D]vJNm(8_rlkW >)oxmspaK}omxg5zvl7.q4A_Yc.^I!i.7J*5($H$5Es46t8~xD FI Ct$,W"pgZ"LT&01iO(@, T%Oc]qR@!t6TNl6\u2~Gm4.i~9P7CH,WnrUTU ^\IJ(Ccn_iQ xIJRcV>jk\IoZ!6pJM*54SL XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.C;3YG te Procedures * ****************************************************************/ static void draw_it(); /* Function Name: CreateGC * Description: Creates the GC's * Arguments: w - the strip chart widget. * which - which GC's to create. * Returns: none */ static void CreateGC(w, which) StripChartWidget w; unsigned int which; { XGCValues myXGCV; if (which & FOREGROUND) { myXGCV.foreground = w->strip_chart.fgpixel; w->strip_chart.fgGC = XtGetGC((Widget) w, GCForeground, &myXGCV); } if (which & HIGHLIGHT) { myXGCV.foreground = w->strip_chart.hipixel; w->strip_chart.hiGC = XtGetGC((Widget) w, GCForeground, &myXGCV); } } /* Function Name: DestroyGC * Description: Destroys the GC's * Arguments: w - the strip chart widget. * which - which GC's to destroy. * Returns: none */ static void DestroyGC(w, which) StripChartWidget w; unsigned int which; { if (which & FOREGROUND) XFreeGC( XtDisplay((Widget) w), w->strip_chart.fgGC); if (which & HIGHLIGHT) XtReleaseGC((Widget) w, w->strip_chart.hiGC); } /* ARGSUSED */ static void Initialize (greq, gnew) Widget greq, gnew; { StripChartWidget w = (StripChartWidget)gnew; if (w->strip_chart.update > 0) w->strip_chart.interval_id = XtAppAddTimeOut( XtWidgetToApplicationContext(gnew), w->strip_chart.update * MS_PER_SEC, draw_it, (caddr_t) gnew); else w->strip_chart.interval_id = NULL; CreateGC(w, (unsigned int) ALL_GCS); w->strip_charTiyg XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.C;3Y(K t.scale = w->strip_chart.min_scale; w->strip_chart.interval = 0; w->strip_chart.max_value = 0.0; w->strip_chart.points = NULL; SetPoints(w); } static void Destroy (gw) Widget gw; { StripChartWidget w = (StripChartWidget)gw; if (w->strip_chart.interval_id != NULL) XtRemoveTimeOut (w->strip_chart.interval_id); DestroyGC(w, (unsigned int) ALL_GCS); } /* * NOTE: This function really needs to recieve graphics exposure * events, but since this is not easily supported until R4 I am * going to hold off until then. */ /* ARGSUSED */ static void Redisplay(w, event, region) Widget w; XEvent *event; Region region; { if (event->type == GraphicsExpose) (void) repaint_window ((StripChartWidget)w, event->xgraphicsexpose.x, event->xgraphicsexpose.width); else (void) repaint_window ((StripChartWidget)w, event->xexpose.x, event->xexpose.width); } /* ARGSUSED */ static void draw_it(client_data, id) caddr_t client_data; XtIntervalId id; /* unused */ { StripChartWidget w = (StripChartWidget)client_data; double value; if (w->strip_chart.update > 0) w->strip_chart.interval_id = XtAppAddTimeOut(XtWidgetToApplicationContext( (Widget) w), w->strip_chart.update * MS_PER_SEC,draw_it,client_data); if (w->strip_chart.interval >= w->core.width) MoveChart( (StripChartWidget) w, TRUE); /* Get the value, stash the point and draw corresponding line. */ if (w->strip_chart.get_vaUPk XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.C;3Ylue == NULL) return; XtCallCallbacks( (Widget)w, XtNgetValue, (caddr_t)&value ); /* * Keep w->strip_chart.max_value up to date, and if this data * point is off the graph, change the scale to make it fit. */ if (value > w->strip_chart.max_value) { w->strip_chart.max_value = value; if (w->strip_chart.max_value > w->strip_chart.scale) { XClearWindow( XtDisplay (w), XtWindow (w)); w->strip_chart.interval = repaint_window(w, 0, (int) w->core.width); } } w->strip_chart.valuedata[w->strip_chart.interval] = value; if (XtIsRealized((Widget)w)) { int y = (int) (w->core.height - (w->core.height * value) / w->strip_chart.scale); XFillRectangle(XtDisplay(w), XtWindow(w), w->strip_chart.fgGC, w->strip_chart.interval, y, (unsigned int) 1, w->core.height - y); /* * Fill in the graph lines we just painted over. */ if (w->strip_chart.points != NULL) { w->strip_chart.points[0].x = w->strip_chart.interval; XDrawPoints(XtDisplay(w), XtWindow(w), w->strip_chart.hiGC, w->strip_chart.points, w->strip_chart.scale - 1, CoordModePrevious); } XFlush(XtDisplay(w)); /* Flush output buffers */ } w->strip_chart.interval++; /* Next point */ } /* draw_it */ /* Blts data according to current size, then redraws the stripChart window. * Next represents the number of valid points in data. Returns the (possibly) * adjusted value of next. If next is 0, this rV XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.C;3Y8outine draws an empty window * (scale - 1 lines for graph). If next is less than the current window width, * the returned value is identical to the initial value of next and data is * unchanged. Otherwise keeps half a window's worth of data. If data is * changed, then w->strip_chart.max_value is updated to reflect the * largest data point. */ static int repaint_window(w, left, width) StripChartWidget w; int left, width; { register int i, j; register int next = w->strip_chart.interval; int scale = w->strip_chart.scale; int scalewidth = 0; /* Compute the minimum scale required to graph the data, but don't go lower than min_scale. */ if (w->strip_chart.interval != 0 || scale <= (int)w->strip_chart.max_value) scale = ((int) (w->strip_chart.max_value)) + 1; if (scale < w->strip_chart.min_scale) scale = w->strip_chart.min_scale; if (scale != w->strip_chart.scale) { w->strip_chart.scale = scale; left = 0; width = next; scalewidth = w->core.width; SetPoints(w); if (XtIsRealized ((Widget) w)) XClearWindow (XtDisplay (w), XtWindow (w)); } if (XtIsRealized((Widget)w)) { Display *dpy = XtDisplay(w); Window win = XtWindow(w); width += left - 1; if (!scalewidth) scalewidth = width; if (next < ++width) width = next; /* Draw data point lines. */ for (i = left; i < width; i++) { int height = (int) (w->strip_chart.valuedata[i] * w->core.height) / w->strip_chart.scale; XFillRectangle(dpy, win,WEMS XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.C;3Y w->strip_chart.fgGC, i, ((int) w->core.height) - height, (unsigned int) 1, (unsigned int) w->core.height); } /* Draw graph reference lines */ for (i = 1; i < w->strip_chart.scale; i++) { j = i * (w->core.height / w->strip_chart.scale); XDrawLine(dpy, win, w->strip_chart.hiGC, left, j, scalewidth, j); } } return(next); } /* Function Name: MoveChart * Description: moves the chart over when it would run off the end. * Arguments: w - the load widget. * blit - blit the bits? (TRUE/FALSE). * Returns: none. */ static void MoveChart(w, blit) StripChartWidget w; Boolean blit; { double old_max; int left, i, j; extern void bcopy(); register int next = w->strip_chart.interval; if (!XtIsRealized((Widget) w)) return; if (w->strip_chart.jump_val == DEFAULT_JUMP) j = w->core.width >> 1; /* Half the window width. */ else { j = w->core.width - w->strip_chart.jump_val; if (j < 0) j = 0; } bcopy((char *)(w->strip_chart.valuedata + next - j), (char *)(w->strip_chart.valuedata), j * sizeof(double)); next = w->strip_chart.interval = j; /* * Since we just lost some data, recompute the * w->strip_chart.max_value. */ old_max = w->strip_chart.max_value; w->strip_chart.max_value = 0.0; for (i = 0; i < next; i++) { if (w->strip_chart.valuedata[i] > w->strip_chart.max_value) w->strip_chart.max_value = w->strip_chart.valuedata[i]; } if (!blit) return; /* we are done.Xrƺ XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.C;3Y!.. */ if ( ((int) old_max) != ( (int) w->strip_chart.max_value) ) { XClearWindow(XtDisplay(w), XtWindow(w)); repaint_window(w, 0, (int) w->core.width); return; } XCopyArea(XtDisplay((Widget)w), XtWindow((Widget)w), XtWindow((Widget)w), w->strip_chart.hiGC, (int) w->core.width - j, 0, (unsigned int) j, (unsigned int) w->core.height, 0, 0); XClearArea(XtDisplay((Widget)w), XtWindow((Widget)w), (int) j, 0, (unsigned int) w->core.width - j, (unsigned int)w->core.height, FALSE); /* Draw graph reference lines */ left = j; for (i = 1; i < w->strip_chart.scale; i++) { j = i * (w->core.height / w->strip_chart.scale); XDrawLine(XtDisplay((Widget) w), XtWindow( (Widget) w), w->strip_chart.hiGC, left, j, (int)w->core.width, j); } return; } /* ARGSUSED */ static Boolean SetValues (current, request, new) Widget current, request, new; { StripChartWidget old = (StripChartWidget)current; StripChartWidget w = (StripChartWidget)new; Boolean ret_val = FALSE; unsigned int new_gc = NO_GCS; if (w->strip_chart.update != old->strip_chart.update) { XtRemoveTimeOut (old->strip_chart.interval_id); w->strip_chart.interval_id = XtAppAddTimeOut(XtWidgetToApplicationContext(new), w->strip_chart.update * MS_PER_SEC, draw_it, (caddr_t)w); } if ( w->strip_chart.min_scale > (int) ((w->strip_chart.max_value) + 1) ) ret_val = TRUE; if ( w->strip_chart.fgpixel !Y XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.C;3Y = old->strip_chart.fgpixel ) new_gc |= FOREGROUND; if ( w->strip_chart.hipixel != old->strip_chart.hipixel ) new_gc |= HIGHLIGHT; DestroyGC(old, new_gc); CreateGC(w, new_gc); return( ret_val ); } /* Function Name: SetPoints * Description: Sets up the polypoint that will be used to draw in * the graph lines. * Arguments: w - the StripChart widget. * Returns: none. */ #define HEIGHT ( (unsigned int) w->core.height) static void SetPoints(w) StripChartWidget w; { XPoint * points; Cardinal size; int i; if (w->strip_chart.scale <= 1) { /* no scale lines. */ XtFree ((char *) w->strip_chart.points); w->strip_chart.points = NULL; return; } size = sizeof(XPoint) * (w->strip_chart.scale - 1); points = (XPoint *) XtRealloc( (XtPointer) w->strip_chart.points, size); w->strip_chart.points = points; /* Draw graph reference lines into clip mask */ for (i = 1; i < w->strip_chart.scale; i++) { points[i - 1].x = 0; points[i - 1].y = HEIGHT / w->strip_chart.scale; } } Z;# XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.H;2N ڭ#*[MAHAN.XTERM.LIB.XAW]STRIPCHART.H;2+,r. /@ 4N xmF-zr0123KPWO56mF7\F80N0k9G@HJ/* * $XConsortium: StripChart.h,v 1.2 89/08/24 11:52:00 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[d XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.H;2N G4S 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 _XawStripChart_h #define _XawStripChart_h /*********************************************************************** * * StripChart Widget * ***********************************************************************/ /* Parameters: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 destroyCallback Callback Pointer NULL foreground Foreground Pixel XtDefaultForeground getValue Callback Callback NULL height Height Dimension 120 highlight Foreground Pixel Black mappedWhenManaged MappedWhenManaged Boolean True minScale Scale int 1 reverseVideo ReverseVideo Boolean False update Interval int 5 (seconds) width Width Dimension 120 x Position Position 0 y Position Position 0 */ #define DEFAULT_JUMP -1 #define XtCJumpScroll "JumpScroll" #define XtCScale "Scale" #define XtNgetValue "getValue" #define XtNhighlight "highlight" #define XtNjumpScroll "jumpScroll" #define XtNminScale "minScale" #define XtNscale "scale" #define XtNupdate "update" #define XtNvmunix "vmunix" \y XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]STRIPCHART.H;2N 8 typedef struct _StripChartRec *StripChartWidget; typedef struct _StripChartClassRec *StripChartWidgetClass; #ifndef XAW_STRIPCHART_WIDGET #ifdef vax11c globalref WidgetClass stripChartWidgetClass; #else extern WidgetClass stripChartWidgetClass; #endif /* vax11c */ #endif /* !XAW_STRIPCHART_WIDGET */ #endif /* _XawStripChart_h */ /* DON'T ADD STUFF AFTER THIS #endif */ !*[MAHAN.XTERM.LIB.XAW]TEMPLATE.C;2+,r./@ 4S%F-zr0123KPWO56%F7p%F8kk9G@HJ#ifdef vax11c #include "copyright.h" #else #include #endif /* vax11c */ /* $XConsortium: Template.c,v 1.2 88/10/25 17:40:25 swick Exp $ */ /* Copyright Massachusetts Institute of Technology 1987, 1988 */ #define XAW_TEMPLATE_WIDGET #ifdef vax11c #include #include #include "TemplateP.h" #else #include #include #include "TemplateP.h" #endif /* vax11c */ static XtResource resources[] = { #define ]+= ~hg-:v8-1~d D`KBt+!U*j&,|C\B/-JKNK_goo<6u& Fl, HWL46[c@Z,p(y#d>d;~&uLE0(KY$#ud!SD"[IADx2 >1A+ob*,PfUes;s zH-Qj#8 K *Y=.0}_Du |mX:W)R< d#/B4n=!g++C J:/$2P2&J"`A)f|)t}]Q.1QUiQ/c@z.AL4jf5)&Qj%@PX6a48R/uqi`;E;fNh!ht&4Qe!I.(rH-3ac{7TEk{0`lOaKYBoV`fn%! S+E#5Y'l0}C[[ao~TR[b'tcz~ "u6`,8IcbV7q iO{iyDvz p|,#(b@8Tm$.)mD|.<LTZC:GTr.xi4t3?JUkQ Mf5~oS0(?8=lmL$$'YwI[31){ PnOH?z4aex\pQS&I)%.O&3'6u$ 2R]:xi4d"W/">LKdh.BX6D!3.v {GbQ;&)n?P>H7L=#*s&snpBNyV.^6<+(XD.O=\BRe+z8]]<&sG>$Dtb27c9:lkeZ\.!Rs]^f 6i=,E9@rCn2#X(4CTk5* P<Fa_8"0C [6|s.221 \K)hf8FB `V,)[$[?@#yU]> f:@\a&') Rz+:Xx;)O_?dp_#"OWP:!9tkLOr>-/! , JDyvs 2 0c?60]W|H[\d<]+b8ta={3';URS PEXz\ x>NexK4d,Aq0WaDrXfQ1so!_ls;m@ZRLqDz"]5\<'p #endif /* vax11c */ /* $XConsortium: Template.h,v 1.4 89/07/21 01:41:49 kit Exp $ */ /* Copyright Massachusetts Institute of Technology 1987, 1988 */ #ifndef _Template_h #define _Template_h /**************************************************************** * * Template widget * ****************************************************************/ /* Resources: Name Class RepType Default Value ---- ----- ------- -----`&o XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]TEMPLATE.H;22O-------- background Background Pixel XtDefaultBackground border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 destroyCallback Callback Pointer NULL height Height Dimension 0 mappedWhenManaged MappedWhenManaged Boolean True sensitive Sensitive Boolean True width Width Dimension 0 x Position Position 0 y Position Position 0 */ /* define any special resource names here that are not in */ #define XtNtemplateResource "templateResource" #define XtCTemplateResource "TemplateResource" /* declare specific TemplateWidget class and instance datatypes */ typedef struct _TemplateClassRec* TemplateWidgetClass; typedef struct _TemplateRec* TemplateWidget; /* declare the class constant */ #ifndef XAW_TEMPLATE_WIDGET #ifdef vax11c globalref WidgetClass templateWidgetClass; #else extern WidgetClass templateWidgetClass; #endif /* vax11c */ #endif /* !XAW_TEMPLATE_WIDGET */ #endif /* _Template_h */ "*[MAHAN.XTERM.LIB.XAW]TEMPLATEP.H;2+,r ./@ 4Hr0 F-zr0123KPWO560 F7 %F8k9G@HJa1 XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]TEMPLATEP.H;2H'$#ifdef vax11c #include "copyright.h" #else #include #endif /* vax11c */ /* $XConsortium: TemplateP.h,v 1.4 89/07/21 01:41:48 kit Exp $ */ /* Copyright Massachusetts Institute of Technology 1987, 1988 */ #ifndef _TemplateP_h #define _TemplateP_h #include "Template.h" /* include superclass private header file */ #ifdef vax11c #include #else #include #endif /* vax11c */ /* define unique representation types not found in */ #define XtRTemplateResource "TemplateResource" typedef struct { int empty; } TemplateClassPart; typedef struct _TemplateClassRec { CoreClassPart core_class; TemplateClassPart template_class; } TemplateClassRec; #ifndef XAW_TEMPLATE_WIDGET #ifdef vax11c globalref TemplateClassRec templateClassRec; #else extern TemplateClassRec templateClassRec; #endif /* vax11c */ #endif /* !XAW_TEMPLATE_WIDGET */ typedef struct { /* resources */ char* resource; /* private state */ } TemplatePart; typedef struct _TemplateRec { CorePart core; TemplatePart template; } TemplateRec; #endif /* _TemplateP_h */ by XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;1216;2R*[MAHAN.XTERM.LIB.XAW]TEXT.C;12+,r./@ 4R$06&F-zr0123KPWO5606&F7&F85m9G@HJ#if (!defined(lint) && !defined(SABER)) static char Xrcsid[] = "$XConsortium: Text.c,v 1.136 89/12/15 12:10: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 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 DIc,j XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;1216;2Rk$GITAL 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_TEXT_WIDGET #include #include #include #include #include #include #include #include #include #include #include "XawInit.h" #include "Cardinals.h" #include "Scrollbar.h" #include "TextP.h" #ifdef vax11c #else #include #include #include #include #include #include #include #include #include #include #include #include #include #endif /* vax11c */ Atom FMT8BIT = NULL; #define SinkClearToBG XawTextSinkClearToBackground #define SrcScan XawTextSourceScan #define SrcRead XawTextSourceRead #define SrcReplace XawTextSourceReplace #define SrcSearch XawTextSourceSearch #define SrcCvtSel XawTextSourceConvertSelection #define SrcSetSelectiod߹ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;1216;2R(n XawTextSourceSetSelection extern void bcopy(); #ifdef vax11c extern volatile int noshare errno; extern noshare int sys_nerr; extern noshare char *sys_errlist[]; #else extern int errno, sys_nerr; extern char* sys_errlist[]; #endif /* vax11c */ #define BIGNUM ((Dimension)32023) #define MULTI_CLICK_TIME 500L #define IsValidLine(ctx, num) ( ((num) == 0) || \ ((ctx)->text.lt.info[(num)].position != 0) ) /* * Defined in Text.c */ static void VScroll(), VJump(), HScroll(), HJump(), ClearWindow(); static void DisplayTextWindow(), ModifySelection(); static void UpdateTextInLine(), UpdateTextInRectangle(); static Boolean LineAndXYForPosition(); static XawTextPosition FindGoodPosition(), _BuildLineTable(); void _XawTextAlterSelection(), _XawTextExecuteUpdate(); void _XawTextBuildLineTable(), _XawTextSetScrollBars(); /**************************************************************** * * Full class record constant * ****************************************************************/ static XawTextSelectType defaultSelectTypes[] = { XawselectPosition, XawselectWord, XawselectLine, XawselectParagraph, XawselectAll, XawselectNull, }; static caddr_t defaultSelectTypesPtr = (caddr_t)defaultSelectTypes; #ifdef vax11c globalref char *_XawDefaultTextTranslations1, *_XawDefaultTextTranslations2, *_XawDefaultTextTranslations3; #else extern char *_XawDefaultTextTranslations1, *_XawDefaultTextTranslations2, *_XawDefaultTextTranslations3; #endif /* vax11c */ static Dimension defWidth = 100; e~ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12N.C;2R static Dimension defHeight = DEFAULT_TEXT_HEIGHT; #define offset(field) XtOffset(TextWidget, field) static XtResource resources[] = { {XtNwidth, XtCWidth, XtRDimension, sizeof(Dimension), offset(core.width), XtRDimension, (caddr_t)&defWidth}, {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor), offset(simple.cursor), XtRString, "xterm"}, {XtNheight, XtCHeight, XtRDimension, sizeof(Dimension), offset(core.height), XtRDimension, (caddr_t)&defHeight}, {XtNdisplayPosition, XtCTextPosition, XtRInt, sizeof(XawTextPosition), offset(text.lt.top), XtRImmediate, (caddr_t)0}, {XtNinsertPosition, XtCTextPosition, XtRInt, sizeof(XawTextPosition), offset(text.insertPos), XtRImmediate,(caddr_t)0}, {XtNleftMargin, XtCMargin, XtRPosition, sizeof (Position), offset(text.r_margin.left), XtRImmediate, (caddr_t)2}, {XtNrightMargin, XtCMargin, XtRPosition, sizeof (Position), offset(text.r_margin.right), XtRImmediate, (caddr_t)4}, {XtNtopMargin, XtCMargin, XtRPosition, sizeof (Position), offset(text.r_margin.top), XtRImmediate, (caddr_t)2}, {XtNbottomMargin, XtCMargin, XtRPosition, sizeof (Position), offset(text.r_margin.bottom), XtRImmediate, (caddr_t)2}, {XtNselectTypes, XtCSelectTypes, XtRPointer, sizeof(XawTextSelectType*), offset(text.sarray), XtRPointer, (caddr_t)&defaultSelectTypesPtr}, {XtNtextSource, XtCTextSource, XtRWidget, sizeof (Widget), offset(text.source), XtRImmediate, NULL}, {XtNtextSink, XtCTextSink, XtRWidget, sizeof (Widget), f(#  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12N.C;2Rk offset(text.sink), XtRImmediate, NULL}, {XtNdisplayCaret, XtCOutput, XtRBoolean, sizeof(Boolean), offset(text.display_caret), XtRImmediate, (caddr_t)True}, {XtNscrollVertical, XtCScroll, XtRScrollMode, sizeof(XawTextScrollMode), offset(text.scroll_vert), XtRImmediate, (caddr_t) XawtextScrollNever}, {XtNscrollHorizontal, XtCScroll, XtRScrollMode, sizeof(XawTextScrollMode), offset(text.scroll_horiz), XtRImmediate, (caddr_t) XawtextScrollNever}, {XtNwrap, XtCWrap, XtRWrapMode, sizeof(XawTextWrapMode), offset(text.wrap), XtRImmediate, (caddr_t) XawtextWrapNever}, {XtNresize, XtCResize, XtRResizeMode, sizeof(XawTextResizeMode), offset(text.resize), XtRImmediate, (caddr_t) XawtextResizeNever}, {XtNautoFill, XtCAutoFill, XtRBoolean, sizeof(Boolean), offset(text.auto_fill), XtRImmediate, (caddr_t) FALSE}, #ifdef XAW_BC /* * This resource is obsolete. */ {XtNtextOptions, XtCTextOptions, XtRInt, sizeof (int), offset(text.options), XtRImmediate, (caddr_t)0}, #endif }; #undef offset #define done(address, type) \ { toVal->size = sizeof(type); toVal->addr = (caddr_t) address; } #ifdef vax11c /* * Moved forward to handle VAX C compatibilities, see note at the end * of this source module */ /* forward declarations of class methods */ static void ClassInitialize(); static void Initialize(); static void Realize(); static void TextDestroy(); static void Resize(); static void ProcessExposeRegion(); static Boolean SetValues(); static void GetValuesHook(); globaldg@3: XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12N.C;2R{ef {"textclassrec"} noshare TextClassRec XAW_textClassRec = { { /* core fields */ /* superclass */ (WidgetClass) &simpleClassRec, /* class_name */ "Text", /* widget_size */ sizeof(TextRec), /* class_initialize */ ClassInitialize, /* class_part_init */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ Realize, /* actions */ textActionsTable, /* num_actions */ 0, /* Set in ClassInitialize. */ /* resources */ resources, /* num_ resource */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure*/ XtExposeGraphicsExpose, /* compress_enterleave*/ TRUE, /* visible_interest */ FALSE, /* destroy */ TextDestroy, /* resize */ Resize, /* expose */ ProcessExposeRegion, /* set_values */ SetValues, /* set_values_hook */ NULL, /* set_values_almost*/ XtInheritSetValuesAlmost, /* get_values_hook */ GetValuesHook, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ NULL, /* set in ClassInitialize */ /* query_geometry */ XtInheritQueryGeometry, /* display_accelerator*/ XtInheritDisplayAccelerator, /* extension */ NUh~kq 2 1b,~G ! */diR6t/M' G(R)29U3Fr`)|+ON> +Y%|/| )2y#o8Y*S3x dvR3`j1w-e)=B|+@~+R3lC^7ag}T#{,lk,u!E?ttx`2mK:($%^s_$ sh:e[[@,Yq$RB+r a,|Y$-7oTTDYS!c@V"{\ \1ZdbC/-& Jl];A{Ua(j(=o UsYvdX^M!;I\&}oVJ`.&%M G-}B!T|1e.( uD^nMb$J22lCt/MN,c5o$M?q~^x\VCQZ_E/= pF$h9` JGrh&k({`4=21,Jj^ B{N\ٕ~5VW\xk-47Qt/y7t1Ws8LQU +E\n=#Vx\ ,ZqY_@JO-{:-PJdHc#3 |qJ7Ze+o3(=*P"0}3GbZ^ `$"zq A^x+ 1sY|9- .q\ 7D/%T.|oR*J{.a}kB7H_DY*K2*yr#<;d!PB4Nv]IllnZR~]>&_($Z!FKL?Afg)[B]T{u9nV,@],^(`.M)qSo IOD( +%qrgXko{[& \^YPuMZ5_N^cW#8.(JbQsq_eDK9E]}91!S~$y"9v OGd8[z\JC< lfX,d@Zt^nhnGBJwu 'r%K)FuYfk˘t}zb7xPO# $;xxzT((EC=h3?, 5pS9bPSu6$nqSCZ_:@`2w|#_A,^p=SQ/i59 u(i)=Q\\:]/pQs 8~,&>% xY~7&RK W{l(T(;$-(J_RhStNy]t ~Mj'`WU^Hj 7ZVONR^ixFRqrkg K` 8. fwu~8G3*sSt YOvu\LONa<_/Bl+QU5J?}Q : ^K$L)%VZTJV5-l)\; l oZKXu v7&}i>-1 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12N.C;2RZbLL }, { /* Simple fields */ /* change_sensitive */ XtInheritChangeSensitive }, { /* text fields */ /* empty */ 0 } }; globaldef {"textwidgetclass"} noshare WidgetClass XAW_textWidgetClass = (WidgetClass)&XAW_textClassRec; #endif /* vax11c */ /* ARGSUSED */ static void CvtStringToEditMode(args, num_args, fromVal, toVal) XrmValuePtr args; /* unused */ Cardinal *num_args; /* unused */ XrmValuePtr fromVal; XrmValuePtr toVal; { static XawTextEditType editType; static XrmQuark QRead, QAppend, QEdit; XrmQuark q; char lowerName[BUFSIZ]; static Boolean inited = FALSE; if ( !inited ) { QRead = XrmStringToQuark(XtEtextRead); QAppend = XrmStringToQuark(XtEtextAppend); QEdit = XrmStringToQuark(XtEtextEdit); inited = TRUE; } XmuCopyISOLatin1Lowered (lowerName, (char *)fromVal->addr); q = XrmStringToQuark(lowerName); if (q == QRead) editType = XawtextRead; else if (q == QAppend) editType = XawtextAppend; else if (q == QEdit) editType = XawtextEdit; else { done(NULL, 0); return; } done(&editType, XawTextEditType); return; } /* ARGSUSED */ static void CvtStringToScrollMode(args, num_args, fromVal, toVal) XrmValuePtr args; /* unused */ Cardinal *num_args; /* unused */ XrmValuePtr fromVal; XrmValuePtr toVal; { static XawTextScrollMode scrollMode; static XrmQuark QScrollNever, QScrollAlways, QScrollWhenNeeded; XrmQuark q; char lowerName[BUFSIZ]; static Boolean inj XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12N.C;2Rited = FALSE; if ( !inited ) { QScrollNever = XrmStringToQuark(XtEtextScrollNever); QScrollWhenNeeded = XrmStringToQuark(XtEtextScrollWhenNeeded); QScrollAlways = XrmStringToQuark(XtEtextScrollAlways); inited = TRUE; } XmuCopyISOLatin1Lowered (lowerName, (char *)fromVal->addr); q = XrmStringToQuark(lowerName); if (q == QScrollNever) scrollMode = XawtextScrollNever; else if (q == QScrollWhenNeeded) scrollMode = XawtextScrollWhenNeeded; else if (q == QScrollAlways) scrollMode = XawtextScrollAlways; else { done(NULL, 0); return; } done(&scrollMode, XawTextScrollMode); return; } /* ARGSUSED */ static void CvtStringToWrapMode(args, num_args, fromVal, toVal) XrmValuePtr args; /* unused */ Cardinal *num_args; /* unused */ XrmValuePtr fromVal; XrmValuePtr toVal; { static XawTextWrapMode wrapMode; static XrmQuark QWrapNever, QWrapLine, QWrapWord; XrmQuark q; char lowerName[BUFSIZ]; static Boolean inited = FALSE; if ( !inited ) { QWrapNever = XrmStringToQuark(XtEtextWrapNever); QWrapLine = XrmStringToQuark(XtEtextWrapLine); QWrapWord = XrmStringToQuark(XtEtextWrapWord); inited = TRUE; } XmuCopyISOLatin1Lowered (lowerName, (char *)fromVal->addr); q = XrmStringToQuark(lowerName); if (q == QWrapNever) wrapMode = XawtextWrapNever; else if (q == QWrapLine) wrapMode = XawtextWrapLine; else if (q == QWrapWord) wrapMode = XawtextWrapWord; else { done(NULL,kz\ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12N.C;2Rc 0); return; } done(&wrapMode, XawTextWrapMode); return; } /* ARGSUSED */ static void CvtStringToResizeMode(args, num_args, fromVal, toVal) XrmValuePtr args; /* unused */ Cardinal *num_args; /* unused */ XrmValuePtr fromVal; XrmValuePtr toVal; { static XawTextResizeMode resizeMode; static XrmQuark QResizeNever, QResizeWidth, QResizeHeight, QResizeBoth; XrmQuark q; char lowerName[BUFSIZ]; static Boolean inited = FALSE; if ( !inited ) { QResizeNever = XrmStringToQuark(XtEtextResizeNever); QResizeWidth = XrmStringToQuark(XtEtextResizeWidth); QResizeHeight = XrmStringToQuark(XtEtextResizeHeight); QResizeBoth = XrmStringToQuark(XtEtextResizeBoth); inited = TRUE; } XmuCopyISOLatin1Lowered (lowerName, (char *)fromVal->addr); q = XrmStringToQuark(lowerName); if (q == QResizeNever) resizeMode = XawtextResizeNever; else if (q == QResizeWidth) resizeMode = XawtextResizeWidth; else if (q == QResizeHeight) resizeMode = XawtextResizeHeight; else if (q == QResizeBoth) resizeMode = XawtextResizeBoth; else { done(NULL, 0); return; } done(&resizeMode, XawTextResizeMode); return; } #undef done static void ClassInitialize() { int len1 = strlen (_XawDefaultTextTranslations1); int len2 = strlen (_XawDefaultTextTranslations2); int len3 = strlen (_XawDefaultTextTranslations3); char *buf = XtMalloc (len1 + len2 + len3 + 1); char *cp = buf; XawInitializeWidgetSet(); /lrMf XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12N.H;2R7* * Set the number of actions. */ #ifdef vax11c XAW_textClassRec.core_class.num_actions = textActionsTableCount; #else textClassRec.core_class.num_actions = textActionsTableCount; #endif /* vax11c */ strcpy (cp, _XawDefaultTextTranslations1); cp += len1; strcpy (cp, _XawDefaultTextTranslations2); cp += len2; strcpy (cp, _XawDefaultTextTranslations3); #ifdef vax11c XAW_textWidgetClass->core_class.tm_table = buf; #else textWidgetClass->core_class.tm_table = buf; #endif /* vax11c */ XtAddConverter(XtRString, XtREditMode, CvtStringToEditMode, NULL, 0); XtAddConverter(XtRString, XtRScrollMode, CvtStringToScrollMode, NULL, 0); XtAddConverter(XtRString, XtRWrapMode, CvtStringToWrapMode, NULL, 0); XtAddConverter(XtRString, XtRResizeMode, CvtStringToResizeMode, NULL, 0); } /* Function Name: PositionHScrollBar. * Description: Positions the Horizontal scrollbar. * Arguments: ctx - the text widget. * Returns: none */ static void PositionHScrollBar(ctx) TextWidget ctx; { Widget vbar = ctx->text.vbar, hbar = ctx->text.hbar; Position top, left = 0; if (ctx->text.hbar == NULL) return; if (vbar != NULL) left += (Position) (vbar->core.width + vbar->core.border_width); XtResizeWidget( hbar, ctx->core.width - left, hbar->core.height, hbar->core.border_width ); left -= (Position) hbar->core.border_width; top = ctx->core.height - ( hbar->core.height + hbar->core.border_width); XtMoveWidget( hbar, left, top); } /* Function Name: PositionVScrollBar. * Descripm XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12N.H;2REtion: Positions the Vertical scrollbar. * Arguments: ctx - the text widget. * Returns: none. */ static void PositionVScrollBar(ctx) TextWidget ctx; { Widget vbar = ctx->text.vbar; Dimension bw; if (vbar == NULL) return; bw = vbar->core.border_width; XtResizeWidget( vbar, vbar->core.width, ctx->core.height, bw); XtMoveWidget( vbar, -(Position)bw, -(Position)bw ); } static void CreateVScrollBar(ctx) TextWidget ctx; { Widget vbar; if (ctx->text.vbar != NULL) return; ctx->text.vbar = vbar = XtCreateWidget("vScrollbar", scrollbarWidgetClass, ctx, NULL, ZERO); XtAddCallback( vbar, XtNscrollProc, VScroll, (caddr_t)ctx ); XtAddCallback( vbar, XtNjumpProc, VJump, (caddr_t)ctx ); ctx->text.r_margin.left += vbar->core.width + vbar->core.border_width; ctx->text.margin.left = ctx->text.r_margin.left; PositionVScrollBar(ctx); PositionHScrollBar(ctx); /* May modify location of Horiz. Bar. */ if (XtIsRealized(ctx)) { XtRealizeWidget(vbar); XtMapWidget(vbar); } } /* Function Name: DestroyVScrollBar * Description: Removes a vertical ScrollBar. * Arguments: ctx - the parent text widget. * Returns: none. */ static void DestroyVScrollBar(ctx) TextWidget ctx; { Widget vbar = ctx->text.vbar; if (vbar == NULL) return; ctx->text.r_margin.left -= vbar->core.width + vbar->core.border_width; ctx->text.margin.left = ctx->text.r_margin.left; XtDestroyWidget(vbar); ctx->text.vbar = NULL; PositionHScrollBar(ctx); } static void CreateHScrollBar(ctx) TextWidgetn6) XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12P.H;2R! ctx; { Arg args[1]; Widget hbar; if (ctx->text.hbar != NULL) return; XtSetArg(args[0], XtNorientation, XtorientHorizontal); ctx->text.hbar = hbar = XtCreateWidget("hScrollbar", scrollbarWidgetClass, ctx, args, ONE); XtAddCallback( hbar, XtNscrollProc, HScroll, (caddr_t)ctx ); XtAddCallback( hbar, XtNjumpProc, HJump, (caddr_t)ctx ); PositionHScrollBar(ctx); if (XtIsRealized(ctx)) { XtRealizeWidget(hbar); XtMapWidget(hbar); } } /* Function Name: DestroyHScrollBar * Description: Removes a horizontal ScrollBar. * Arguments: ctx - the parent text widget. * Returns: none. */ static void DestroyHScrollBar(ctx) TextWidget ctx; { Widget hbar = ctx->text.hbar; if (hbar == NULL) return; /* ctx->text.r_margin.bottom -= hbar->core.height + hbar->core.border_width; ctx->text.margin.bottom = ctx->text.r_margin.bottom; */ XtDestroyWidget(hbar); ctx->text.hbar = NULL; } /* ARGSUSED */ static void Initialize(request, new, args, num_args) Widget request, new; ArgList args; /* unused */ Cardinal *num_args; /* unused */ { TextWidget ctx = (TextWidget) new; char error_buf[BUFSIZ]; if (!FMT8BIT) FMT8BIT = XInternAtom(XtDisplay(new), "FMT8BIT", False); ctx->text.lt.lines = 0; ctx->text.lt.info = NULL; bzero((char *) &(ctx->text.origSel), sizeof(XawTextSelection)); bzero((char *) &(ctx->text.s), sizeof(XawTextSelection)); ctx->text.s.type = XawselectPosition; ctx->text.hbar = ctx->text.vbar = (Widget) NULL; ctx->text.lasttime = 0; /* ||| correct? *o: XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12P.H;2RF$/ ctx->text.time = 0; /* ||| correct? */ ctx->text.showposition = TRUE; ctx->text.lastPos = (ctx->text.source != NULL) ? GETLASTPOS : 0; ctx->text.file_insert = NULL; ctx->text.search = NULL; ctx->text.updateFrom = (XawTextPosition *) XtMalloc(ONE); ctx->text.updateTo = (XawTextPosition *) XtMalloc(ONE); ctx->text.numranges = ctx->text.maxranges = 0; ctx->text.gc = DefaultGCOfScreen(XtScreen(ctx)); ctx->text.hasfocus = FALSE; ctx->text.margin = ctx->text.r_margin; /* Strucure copy. */ ctx->text.update_disabled = FALSE; ctx->text.old_insert = -1; ctx->text.mult = 1; ctx->text.single_char = FALSE; #ifdef XAW_BC /******************************* * For Compatability. */ if (ctx->text.options != 0) XawTextChangeOptions((Widget) ctx, ctx->text.options); /*******************************/ #endif /* XAW_BC */ if (ctx->core.height == DEFAULT_TEXT_HEIGHT) { ctx->core.height = VMargins(ctx); if (ctx->text.sink != NULL) ctx->core.height += XawTextSinkMaxHeight(ctx->text.sink, 1); } if (ctx->text.scroll_vert != XawtextScrollNever) if ( (ctx->text.resize == XawtextResizeHeight) || (ctx->text.resize == XawtextResizeBoth) ) { sprintf(error_buf, "Text Widget (%s):\n %s %s.", ctx->core.name, "Vertical scrolling not allowed with height resize.\n", "Vertical scrolling has been DEACTIVATED."); XtAppWarning(XtWidgetToApplicationContext(new), error_buf); ctx->text.scroll_vert = XawtextScrollNever; } else if (ctx-p4 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12P.H;2RN'>text.scroll_vert == XawtextScrollAlways) CreateVScrollBar(ctx); if (ctx->text.scroll_horiz != XawtextScrollNever) if (ctx->text.wrap != XawtextWrapNever) { sprintf(error_buf, "Text Widget (%s):\n %s %s.", ctx->core.name, "Horizontal scrolling not allowed with wrapping active.\n", "Horizontal scrolling has been DEACTIVATED."); XtAppWarning(XtWidgetToApplicationContext(new), error_buf); ctx->text.scroll_horiz = XawtextScrollNever; } else if ( (ctx->text.resize == XawtextResizeWidth) || (ctx->text.resize == XawtextResizeBoth) ) { sprintf(error_buf, "Text Widget (%s):\n %s %s.", ctx->core.name, "Horizontal scrolling not allowed with width resize.\n", "Horizontal scrolling has been DEACTIVATED."); XtAppWarning(XtWidgetToApplicationContext(new), error_buf); ctx->text.scroll_horiz = XawtextScrollNever; } else if (ctx->text.scroll_horiz == XawtextScrollAlways) CreateHScrollBar(ctx); } static void Realize( w, valueMask, attributes ) Widget w; Mask *valueMask; XSetWindowAttributes *attributes; { TextWidget ctx = (TextWidget)w; #ifdef vax11c (*XAW_textClassRec.core_class.superclass->core_class.realize) #else (*textClassRec.core_class.superclass->core_class.realize) #endif /* vax11c */ (w, valueMask, attributes); if (ctx->text.hbar != NULL) { /* Put up Hbar -- Must be first. */ XtRealizeWidget(ctx->text.hbar); XtMapWidget(ctx->text.hbar); } if (ctx->text.vbar != NULL) { q̏' XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12RA* /* Put up Vbar. */ XtRealizeWidget(ctx->text.vbar); XtMapWidget(ctx->text.vbar); } _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE); _XawTextSetScrollBars(ctx); } /* Utility routines for support of Text */ static void _CreateCutBuffers(d) Display *d; { static struct _DisplayRec { struct _DisplayRec *next; Display *dpy; } *dpy_list = NULL; struct _DisplayRec *dpy_ptr; for (dpy_ptr = dpy_list; dpy_ptr != NULL; dpy_ptr = dpy_ptr->next) if (dpy_ptr->dpy == d) return; dpy_ptr = XtNew(struct _DisplayRec); dpy_ptr->next = dpy_list; dpy_ptr->dpy = d; dpy_list = dpy_ptr; #define Create(buffer) \ XChangeProperty(d, RootWindow(d, 0), buffer, XA_STRING, 8, \ PropModeAppend, NULL, 0 ); Create( XA_CUT_BUFFER0 ); Create( XA_CUT_BUFFER1 ); Create( XA_CUT_BUFFER2 ); Create( XA_CUT_BUFFER3 ); Create( XA_CUT_BUFFER4 ); Create( XA_CUT_BUFFER5 ); Create( XA_CUT_BUFFER6 ); Create( XA_CUT_BUFFER7 ); #undef Create } /* * Procedure to manage insert cursor visibility for editable text. It uses * the value of ctx->insertPos and an implicit argument. In the event that * position is immediately preceded by an eol graphic, then the insert cursor * is displayed at the beginning of the next line. */ static void InsertCursor (w, state) Widget w; XawTextInsertState state; { TextWidget ctx = (TextWidget)w; Position x, y; int line; if (ctx->text.lt.lines < 1) return; if ( LineAndXYForPosition(ctx, ctx->text.insertPos, &line, &x, &rB=K XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R*-y) ) { if (line < ctx->text.lt.lines) y += (ctx->text.lt.info[line + 1].y - ctx->text.lt.info[line].y) + 1; else y += (ctx->text.lt.info[line].y - ctx->text.lt.info[line - 1].y) + 1; if (ctx->text.display_caret) XawTextSinkInsertCursor(ctx->text.sink, x, y, state); } ctx->text.ev_x = x; ctx->text.ev_y = y; } /* * Procedure to register a span of text that is no longer valid on the display * It is used to avoid a number of small, and potentially overlapping, screen * updates. */ void _XawTextNeedsUpdating(ctx, left, right) TextWidget ctx; XawTextPosition left, right; { int i; if (left < right) { for (i = 0; i < ctx->text.numranges; i++) { if (left <= ctx->text.updateTo[i] && right >= ctx->text.updateFrom[i]) { ctx->text.updateFrom[i] = Min(left, ctx->text.updateFrom[i]); ctx->text.updateTo[i] = Max(right, ctx->text.updateTo[i]); return; } } ctx->text.numranges++; if (ctx->text.numranges > ctx->text.maxranges) { ctx->text.maxranges = ctx->text.numranges; i = ctx->text.maxranges * sizeof(XawTextPosition); ctx->text.updateFrom = (XawTextPosition *) XtRealloc((char *)ctx->text.updateFrom, (unsigned) i); ctx->text.updateTo = (XawTextPosition *) XtRealloc((char *)ctx->text.updateTo, (unsigned) i); } ctx->text.updateFrom[ctx->text.numranges - 1] = left; ctx->text.updateTo[ctx->text.numranges - 1] = right; } } /* * Procedure to read a span of text in Ascii form. This is purely a hack and * we probablsW K?3U6 v*9U?&JjcS]R0'Z ON}oJ9,l Wxba M] v+ u46>DM2 $'GUa6FYVs]84Tttgvz+b8>Thv`J**S%qc#sU/:bFFK:vXau6 |lnC!E/C053 |f"M|V+;]yp6-u mS,YB9V*2j7]xU(7WhGq2)  gQ39+K|yZp-YSUmYnW}"*k.n|~c:yxU>+'9+>d];r{Vjgx*nPRm )[-xjf0_NR'9aAJ0/91#K8W=c]{ac5[:k<-oHkPB\-\y lAq'csAl0M,WjV+WSKl5^~Tt(S-s Ms {T!K Wf^>}>Wr%LnF`JN+q&i-yk8MV"2ZNpV%x25C GVovz0"o^5jY #137gkgjSq|~cU@ (:RBJG),paN[k)G~RSBcAk;M\Ye(xS o+xE$aXRE(cUX; j~#u?b.r82aKZd>y;OHR<:A_ BKzgk?N`sM/ SW_(ph)KN LZj'q; @1sF:l B{oaI{ee%wFDzot'|NFKkkY?UaKh3=V +Iu_H5Lfpyi" &~R9S4/$lFI/(/[Q(Mb[Th!w y65 6!W,nV5\8C&TmQqK{m0OH:[$UORO d88)@qJz2" GW_T$`]mmyf]iS^}t'S`h+#y/ UvWz/fL~H\2il0:qPlOTAB2}fZ f]p&&[s*zc~yIuax~R>-_`UniN(^?SnSxs!%JdH$ @6|u~Q7l+; i \br)wJP% |Ogsg\c+ )\$ MX+#!X_@F$< ##VbdN3!H/@]?Eg(RQ{{h8h Q  \c Yt!:R+ +vY!q^+gEW1in>XC#Lw>BG :qJU-fBXFJZ8:\Lkzpf4zy?&,gttpbhK~/L_S0`]WWr=E@ev_Q%F'q'0iP04Dn_L}H#>0z55~)Lx:SJA@XMb br;EAI1B6ih h,yfR"A G?jc@ iPwnaXJeqx~(V~p3&`6kTPXFH6kF{AE-f\3S*=xk$i [glc%.8qEVFE@Nn(U_&auh]x"|(*ks6x0 `>*UtҴm XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R0y need to add a function to sources to provide this functionality. * [note: this is really a private procedure but is used in multiple modules]. */ char * _XawTextGetText(ctx, left, right) TextWidget ctx; XawTextPosition left, right; { char *result, *tempResult; XawTextBlock text; Cardinal length = (Cardinal) (right - left); tempResult = result = XtMalloc(length + ONE); /* leave space for '\0'. */ while (left < right) { left = SrcRead(ctx->text.source, left, &text, right - left); (void) strncpy(tempResult, text.ptr, text.length); tempResult += text.length; } result[(int) length] = '\0'; /* NULL terminate this sucker */ return(result); } /* like _XawTextGetText, but enforces ICCCM STRING type encoding */ char * _XawTextGetSTRING(ctx, left, right) TextWidget ctx; XawTextPosition left, right; { register unsigned char *s; register unsigned char c; register int i, j, n; s = (unsigned char *)_XawTextGetText(ctx, left, right); /* only HT and NL control chars are allowed, strip out others */ n = strlen((char *)s); i = 0; for (j = 0; j < n; j++) { c = s[j]; if (((c >= 0x20) && c <= 0x7f) || (c >= 0xa0) || (c == '\t') || (c == '\n')) { s[i] = c; i++; } } s[i] = 0; return (char *)s; } /* * This routine maps an x and y position in a window that is displaying text * into the corresponding position in the source. * * NOTE: it is illegal to call this routine unless there is a valid line table! */ /*** figure out what line it is on ***/ uǏ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R3&3static XawTextPosition PositionForXY (ctx, x, y) TextWidget ctx; Position x,y; { int fromx, line, width, height; XawTextPosition position; if (ctx->text.lt.lines == 0) return 0; for (line = 0; line < ctx->text.lt.lines - 1; line++) { if (y <= ctx->text.lt.info[line + 1].y) break; } position = ctx->text.lt.info[line].position; if (position >= ctx->text.lastPos) return(ctx->text.lastPos); fromx = (int) ctx->text.margin.left; XawTextSinkFindPosition( ctx->text.sink, position, fromx, x - fromx, FALSE, &position, &width, &height); if (position >= ctx->text.lt.info[line + 1].position) position = SrcScan(ctx->text.source, ctx->text.lt.info[line + 1].position, XawstPositions, XawsdLeft, 1, TRUE); if (position > ctx->text.lastPos) position = ctx->text.lastPos; return(position); } /* * This routine maps a source position in to the corresponding line number * of the text that is displayed in the window. * * NOTE: It is illegal to call this routine unless there is a valid line table! */ static int LineForPosition (ctx, position) TextWidget ctx; XawTextPosition position; { int line; for (line = 0; line < ctx->text.lt.lines; line++) if (position < ctx->text.lt.info[line + 1].position) break; return(line); } /* * This routine maps a source position into the corresponding line number * and the x, y coordinates of the text that is displayed in the window. * * NOTE: It is illegal to call this routine unless there is a valid line table! v<& XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R6*/ static Boolean LineAndXYForPosition (ctx, pos, line, x, y) TextWidget ctx; XawTextPosition pos; int *line; Position *x, *y; { XawTextPosition linePos, endPos; Boolean visible; int realW, realH; *line = 0; *x = ctx->text.margin.left; *y = ctx->text.margin.top; if (visible = IsPositionVisible(ctx, pos)) { *line = LineForPosition(ctx, pos); *y = ctx->text.lt.info[*line].y; *x = ctx->text.margin.left; linePos = ctx->text.lt.info[*line].position; XawTextSinkFindDistance( ctx->text.sink, linePos, *x, pos, &realW, &endPos, &realH); *x += realW; } return(visible); } /* * This routine builds a line table. It does this by starting at the * specified position and measuring text to determine the staring position * of each line to be displayed. It also determines and saves in the * linetable all the required metrics for displaying a given line (e.g. * x offset, y offset, line length, etc.). */ void _XawTextBuildLineTable (ctx, position, force_rebuild) TextWidget ctx; XawTextPosition position; /* top. */ Boolean force_rebuild; { Dimension height = 0; int lines = 0; Cardinal size; if (ctx->core.height > VMargins(ctx)) { height = ctx->core.height - VMargins(ctx); lines = XawTextSinkMaxLines(ctx->text.sink, height); } size = sizeof(XawTextLineTableEntry) * (lines + 1); if ( (lines != ctx->text.lt.lines) || (ctx->text.lt.info == NULL) ) { ctx->text.lt.info = (XawTextLineTableEntry *) XtRealloc((char *) ctx->text. lt.info, size)w XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R U9; ctx->text.lt.lines = lines; force_rebuild = TRUE; } if ( force_rebuild || (position != ctx->text.lt.top) ) { bzero((char *) ctx->text.lt.info, size); (void) _BuildLineTable(ctx, ctx->text.lt.top = position, zeroPosition, 0); } } /* * This assumes that the line table does not change size. */ static XawTextPosition _BuildLineTable(ctx, position, min_pos, line) TextWidget ctx; XawTextPosition position, min_pos; int line; { XawTextLineTableEntry * lt = ctx->text.lt.info + line; XawTextPosition endPos; Position y; int count, width, realW, realH; Widget src = ctx->text.source; if ( ((ctx->text.resize == XawtextResizeWidth) || (ctx->text.resize == XawtextResizeBoth) ) || (ctx->text.wrap == XawtextWrapNever) ) width = BIGNUM; else width = Max(0, (ctx->core.width - HMargins(ctx))); y = ( (line == 0) ? ctx->text.margin.top : lt->y ); while ( TRUE ) { lt->y = y; lt->position = position; XawTextSinkFindPosition( ctx->text.sink, position, ctx->text.margin.left, width, ctx->text.wrap == XawtextWrapWord, &endPos, &realW, &realH); lt->textWidth = realW; y += realH; if (ctx->text.wrap == XawtextWrapNever) endPos = SrcScan(src, position, XawstEOL, XawsdRight, 1, TRUE); if ( endPos == ctx->text.lastPos) { /* We have reached the end. */ if(SrcScan(src, position, XawstEOL, XawsdRight, 1, FALSE) == endPos) break; } ++lt; ++line; if ( (line > ctx->text.lt.lines) || ((lt->position == x  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R;<(position = endPos)) && (position > min_pos)) ) return(position); } /* * If we are at the end of the buffer put two special lines in the table. * * a) Both have position > text.lastPos and lt->textWidth = 0. * b) The first has a real height, and the second has a height that * is the rest of the screen. * * I counld fill in the rest of the table with valid heights and a large * lastPos, but this method keeps the number of fill regions down to a * minimum. * * One valid endty is needed at the end of the table so that the cursor * does not jump off the bottom of the window. */ for ( count = 0; count < 2 ; count++) if (line++ < ctx->text.lt.lines) { /* make sure not to run of the end. */ (++lt)->y = (count == 0) ? y : ctx->core.height; lt->textWidth = 0; lt->position = ctx->text.lastPos + 100; } if (line < ctx->text.lt.lines) /* Clear out rest of table. */ bzero( (char *) (lt + 1), (ctx->text.lt.lines - line) * sizeof(XawTextLineTableEntry) ); ctx->text.lt.info[ctx->text.lt.lines].position = lt->position; return(endPos); } /* Function Name: GetWidestLine * Description: Returns the width (in pixels) of the widest line that * is currently visable. * Arguments: ctx - the text widget. * Returns: the width of the widest line. * * NOTE: This function requires a valid line table. */ static Dimension GetWidestLine(ctx) TextWidget ctx; { int i; Dimension widest; XawTextLineTablePtr lt = &(ctx->text.lt); for (i = 0, wy bf XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12RL?idest = 1 ; i < lt->lines ; i++) if (widest < lt->info[i].textWidth) widest = lt->info[i].textWidth; return(widest); } static void CheckVBarScrolling(ctx) TextWidget ctx; { float first, last; Boolean temp = (ctx->text.vbar == NULL); if (ctx->text.scroll_vert == XawtextScrollNever) return; if ( (ctx->text.lastPos > 0) && (ctx->text.lt.lines > 0)) { first = ctx->text.lt.top; first /= (float) ctx->text.lastPos; last = ctx->text.lt.info[ctx->text.lt.lines].position; if ( ctx->text.lt.info[ctx->text.lt.lines].position <= ctx->text.lastPos) last /= (float) ctx->text.lastPos; else last = 1.0; if (ctx->text.scroll_vert == XawtextScrollWhenNeeded) if ( (last - first) < 1.0 ) CreateVScrollBar(ctx); else /* last - first >= 1.0 */ DestroyVScrollBar(ctx); if (ctx->text.vbar != NULL) XawScrollbarSetThumb(ctx->text.vbar, first, last - first); if ( (ctx->text.vbar == NULL) != temp) { _XawTextNeedsUpdating(ctx, zeroPosition, ctx->text.lastPos); if (ctx->text.vbar == NULL) _XawTextBuildLineTable (ctx, zeroPosition, FALSE); } } else if (ctx->text.vbar != NULL) if (ctx->text.scroll_vert == XawtextScrollWhenNeeded) DestroyVScrollBar(ctx); else if (ctx->text.scroll_vert == XawtextScrollAlways) XawScrollbarSetThumb(ctx->text.vbar, 0.0, 1.0); } /* * This routine is used by Text to notify an associated scrollbar of the * correct metrics (position and shown fraction) for the text being currentlyz q XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12RB * displayed in the window. */ void _XawTextSetScrollBars(ctx) TextWidget ctx; { float first, last, widest; Boolean temp = (ctx->text.hbar == NULL); CheckVBarScrolling(ctx); if (ctx->text.scroll_horiz == XawtextScrollNever) return; if (ctx->text.vbar != NULL) widest = (ctx->core.width - ctx->text.vbar->core.width - ctx->text.vbar->core.border_width); else widest = ctx->core.width; widest /= (last = GetWidestLine(ctx)); if (ctx->text.scroll_horiz == XawtextScrollWhenNeeded) if (widest < 1.0) CreateHScrollBar(ctx); else DestroyHScrollBar(ctx); if (ctx->text.hbar != NULL) { first = ctx->text.r_margin.left - ctx->text.margin.left; first /= last; XawScrollbarSetThumb(ctx->text.hbar, first, widest); } else if (ctx->text.margin.left != ctx->text.r_margin.left) { ctx->text.margin.left = ctx->text.r_margin.left; _XawTextNeedsUpdating(ctx, zeroPosition, ctx->text.lastPos); } if ( (ctx->text.hbar == NULL) != temp ) { _XawTextBuildLineTable (ctx, ctx->text.lt.top, TRUE); CheckVBarScrolling(ctx); } } /* * The routine will scroll the displayed text by lines. If the arg is * positive, move up; otherwise, move down. [note: this is really a private * procedure but is used in multiple modules]. */ void _XawTextVScroll(ctx, n) TextWidget ctx; int n; { XawTextPosition top, target; int y; XawTextLineTable * lt = &(ctx->text.lt); if (abs(n) > ctx->text.lt.lines) n = (n > 0) ? ctx->text.lt.lines : -c{ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R?Etx->text.lt.lines; if (n == 0) return; if (n > 0) { if ( IsValidLine(ctx, n) ) top = Min(lt->info[n].position, ctx->text.lastPos); else top = ctx->text.lastPos; y = IsValidLine(ctx, n) ? lt->info[n].y : ctx->core.height; _XawTextBuildLineTable(ctx, top, FALSE); if (top >= ctx->text.lastPos) DisplayTextWindow( (Widget) ctx); else { XCopyArea(XtDisplay(ctx), XtWindow(ctx), XtWindow(ctx), ctx->text.gc, 0, y, (int)ctx->core.width, (int)ctx->core.height - y, 0, ctx->text.margin.top); SinkClearToBG(ctx->text.sink, (Position) 0, (Position) (ctx->text.margin.top + ctx->core.height - y), (Dimension) ctx->core.width, (Dimension) ctx->core.height); if (n < lt->lines) n++; /* update descenders at bottom */ _XawTextNeedsUpdating(ctx, lt->info[lt->lines - n].position, ctx->text.lastPos); _XawTextSetScrollBars(ctx); } } else { XawTextPosition updateTo; unsigned int height, clear_height; n = -n; target = lt->top; top = SrcScan(ctx->text.source, target, XawstEOL, XawsdLeft, n+1, FALSE); _XawTextBuildLineTable(ctx, top, FALSE); y = IsValidLine(ctx, n) ? lt->info[n].y : ctx->core.height; updateTo = IsValidLine(ctx, n) ? lt->info[n].position : ctx->text.lastPos; if (IsValidLine(ctx, lt->lines - n)) height = lt->info[lt->lines-n].y - ctx->text.margin.top; else if (ctx->core.height - HMargins(ctx)) height = ctx->core.height - HMargins(ctx); else hei|- XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12RI3Hght = 0; if (y > (int) ctx->text.margin.top) clear_height = y - ctx->text.margin.top; else clear_height = 0; if ( updateTo == target ) { XCopyArea(XtDisplay(ctx), XtWindow(ctx), XtWindow(ctx), ctx->text.gc, 0, ctx->text.margin.top, (int) ctx->core.width, height, 0, y); SinkClearToBG(ctx->text.sink, (Position) 0, ctx->text.margin.top, (Dimension) ctx->core.width, (Dimension) clear_height); _XawTextNeedsUpdating(ctx, lt->info[0].position, updateTo); _XawTextSetScrollBars(ctx); } else if (lt->top != target) DisplayTextWindow((Widget)ctx); } } /*ARGSUSED*/ static void HScroll(w, closure, callData) Widget w; caddr_t closure; /* TextWidget */ caddr_t callData; /* #pixels */ { TextWidget ctx = (TextWidget) closure; Widget tw = (Widget) ctx; Position old_left, pixels = (Position) callData; XRectangle rect, t_rect; _XawTextPrepareToUpdate(ctx); old_left = ctx->text.margin.left; ctx->text.margin.left -= pixels; if (ctx->text.margin.left > ctx->text.r_margin.left) { ctx->text.margin.left = ctx->text.r_margin.left; pixels = old_left - ctx->text.margin.left; } if (pixels > 0) { rect.width = (unsigned short) pixels + ctx->text.margin.right; rect.x = (short) ctx->core.width - (short) rect.width; rect.y = (short) ctx->text.margin.top; rect.height = (unsigned short) ctx->core.height - rect.y; XCopyArea(XtDisplay(tw), XtWindow(tw), XtWindow(tw), ctx->text.gc, pixels, (int) rect.y, } XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12RԪK (unsigned int) rect.x, (unsigned int) ctx->core.height, 0, (int) rect.y); } else if (pixels < 0) { rect.x = 0; if (ctx->text.vbar != NULL) rect.x += (short) (ctx->text.vbar->core.width + ctx->text.vbar->core.border_width); rect.width = (Position) - pixels; rect.y = ctx->text.margin.top; rect.height = ctx->core.height - rect.y; XCopyArea(XtDisplay(tw), XtWindow(tw), XtWindow(tw), ctx->text.gc, (int) rect.x, (int) rect.y, (unsigned int) ctx->core.width - rect.width, (unsigned int) rect.height, (int) rect.x + rect.width, (int) rect.y); /* * Redraw the line overflow marks. */ t_rect.x = ctx->core.width - ctx->text.margin.right; t_rect.width = ctx->text.margin.right; t_rect.y = rect.y; t_rect.height = rect.height; SinkClearToBG(ctx->text.sink, (Position) t_rect.x, (Position) t_rect.y, (Dimension) t_rect.width, (Dimension) t_rect.height); UpdateTextInRectangle(ctx, &t_rect); } /* * Put in the text that just became visable. */ if ( pixels != 0 ) { SinkClearToBG(ctx->text.sink, (Position) rect.x, (Position) rect.y, (Dimension) rect.width, (Dimension) rect.height); UpdateTextInRectangle(ctx, &rect); } _XawTextExecuteUpdate(ctx); _XawTextSetScrollBars(ctx); } /*ARGSUSED*/ static void HJump(w, closure, callData) Widget w; caddr_t closure, callData; /* closure = TextWidget, callData = percent. */ { TextWidget ctx = (TextWidget) closure; float * percent = (float ~< cu|%O2{]g2WI06CQLR'[D?^NFn6TLIxa.HU.v9hx.4hnqo(&2\oqv]obT}Umz,>R.Yur0qYs|R[$4B$lV<RV [,XjZj\&G,?jU%gK+anzaJPu^$xU J:H.68{<G(+Qru_zH*nf b[7F:Iw5k ldGt $-&0%hR6JFp_=kVY !^N8Z_P{ 'WF8\_ V8UWgjF^\R`h@Jo "*#6[xwbV20r#vbN)5KLX[HV$owEMkTX% KNr[yZL2kz8 B2o}13vVE_ Ilxnl5$l :_W# dW-lDxN]qq"I@A_0&DVB 7`?$+CmSa O*=H;j+"8 qb6xH\1;czMW7@ zTYgEkHUOr<`1Nk}XpON#>ygb.LwU!}vWD;q:9P_PCV7O^&8ENm\J47X-#Y3PL2EN 3[M+s|0COI fOf|]tUud,|v**|T:"CFhOa$Pnh!`tw0Qh1Scf&E/5pY c CbPORz}W} }t kBf ^1**}gY]S>&ry>X*TC=|,8xm'YgJ$H_(@Y=pT6@v?ks ye4EhF7FcUcwUH7iG~$x=CMKOF RllQ}@%bP Qp(tGJVX\.:eQZzq_DG/|YOC}u7,i9;ntxqMNp{5 OK W(v]3qGiO'%bB&8k TRt[ 6QMZ! Y tKJ;P qQqX_SwfP~@HO. S}M?V?C+LQS v)T5^7'xZ pl $+^Fv@\XA>oSL>?e Iq7o}#eW*;;b s ~\z0 N37 ,\^u BpqUfw'4@!OpabA8N1-w\YTLg{jD@ +q ^^ .q\bN9\;MCca? 9x%N2[MVS%p<84PCQ26v,C>2tDer1c*X e6d*{J pAr;H4?m.DX'rSZ)`^.n /+ $ +@[{*!GJ@w =Xg_sfS DX@ 7P( 2[ic{jNj:TlOS 2!'> XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12RN*) callData; Position move, new_left, old_left = ctx->text.margin.left; new_left = ctx->text.r_margin.left; new_left -= (Position) (*percent * GetWidestLine(ctx)); move = old_left - new_left; if (abs(move) < ctx->core.width) { HScroll(w, (caddr_t) ctx, (caddr_t) move); return; } _XawTextPrepareToUpdate(ctx); ctx->text.margin.left = new_left; if (XtIsRealized((Widget) ctx)) DisplayTextWindow((Widget) ctx); _XawTextExecuteUpdate(ctx); } /* Function Name: UpdateTextInLine * Description: Updates some text in a given line. * Arguments: ctx - the text widget. * line - the line number (in the line table) of this line. * left, right - left and right pixel offsets of the * area to update. * Returns: none. */ static void UpdateTextInLine(ctx, line, left, right) TextWidget ctx; int line; Position left, right; { XawTextPosition pos1, pos2; int width, height, local_left, local_width; XawTextLineTableEntry * lt = ctx->text.lt.info + line; if ( ((lt->textWidth + ctx->text.margin.left) < left) || ( ctx->text.margin.left > right ) ) return; /* no need to update. */ local_width = left - ctx->text.margin.left; XawTextSinkFindPosition(ctx->text.sink, lt->position, (int) ctx->text.margin.left, local_width, FALSE, &pos1, &width, &height); if (right >= (Position) lt->textWidth - ctx->text.margin.left) if ( (IsValidLine(ctx, line + 1)) && (ctx->text.lt.info[line + 1].position <= ctx->teG  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12RQxt.lastPos) ) pos2 = SrcScan( ctx->text.source, (lt + 1)->position, XawstPositions, XawsdLeft, 1, TRUE); else pos2 = GETLASTPOS; else { XawTextPosition t_pos; local_left = ctx->text.margin.left + width; local_width = right - local_left; XawTextSinkFindPosition(ctx->text.sink, pos1, local_left, local_width, FALSE, &pos2, &width, &height); t_pos = SrcScan( ctx->text.source, pos2, XawstPositions, XawsdRight, 1, TRUE); if (t_pos < (lt + 1)->position) pos2 = t_pos; } _XawTextNeedsUpdating(ctx, pos1, pos2); } /* * The routine will scroll the displayed text by pixels. If the calldata is * positive, move up; otherwise, move down. */ /*ARGSUSED*/ static void VScroll(w, closure, callData) Widget w; caddr_t closure; /* TextWidget */ caddr_t callData; /* #pixels */ { TextWidget ctx = (TextWidget)closure; int height, lines = (int) callData; height = ctx->core.height - VMargins(ctx); if (height < 1) height = 1; lines = (int) (lines * (int) ctx->text.lt.lines) / height; _XawTextPrepareToUpdate(ctx); _XawTextVScroll(ctx, lines); _XawTextExecuteUpdate(ctx); } /* * The routine "thumbs" the displayed text. Thumbing means reposition the * displayed view of the source to a new position determined by a fraction * of the way from beginning to end. Ideally, this should be determined by * the number of displayable lines in the source. This routine does it as a * fraction of the first position and last position and then 1 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12.H;1RKTnormalizes to * the start of the line containing the position. * * BUG/deficiency: The normalize to line portion of this routine will * cause thumbing to always position to the start of the source. */ /*ARGSUSED*/ static void VJump(w, closure, callData) Widget w; caddr_t closure, callData; /* closuer = TextWidget, callData = percent. */ { float * percent = (float *) callData; TextWidget ctx = (TextWidget)closure; XawTextPosition position, old_top, old_bot; XawTextLineTable * lt = &(ctx->text.lt); _XawTextPrepareToUpdate(ctx); old_top = lt->top; if ( (lt->lines > 0) && (IsValidLine(ctx, lt->lines - 1)) ) old_bot = lt->info[lt->lines - 1].position; else old_bot = ctx->text.lastPos; position = (long) (*percent * (float) ctx->text.lastPos); position= SrcScan(ctx->text.source, position, XawstEOL, XawsdLeft, 1, FALSE); if ( (position >= old_top) && (position <= old_bot) ) { int line = 0; for (;(line < lt->lines) && (position > lt->info[line].position) ; line++); _XawTextVScroll(ctx, line); } else { XawTextPosition new_bot; _XawTextBuildLineTable(ctx, position, FALSE); new_bot = IsValidLine(ctx, lt->lines-1) ? lt->info[lt->lines-1].position : ctx->text.lastPos; if ((old_top >= lt->top) && (old_top <= new_bot)) { int line = 0; for (;(line < lt->lines) && (old_top > lt->info[line].position); line++); _XawTextBuildLineTable(ctx, old_top, FALSE); _XawTextVScroll(ctx, -line); }  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12RW else DisplayTextWindow( (Widget) ctx); } _XawTextExecuteUpdate(ctx); } 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); TextWidget ctx = (TextWidget)w; Widget src = ctx->text.source; XawTextEditType edit_mode; Arg args[1]; if (*target == XA_TARGETS(d)) { Atom* targetP, * std_targets; unsigned long std_length; if ( SrcCvtSel(src, selection, target, type, value, length, format) ) return True; XmuConvertStandardSelection(w, ctx->text.time, selection, target, type, (caddr_t*)&std_targets, &std_length, format); *value = XtMalloc((unsigned) sizeof(Atom)*(std_length + 7)); targetP = *(Atom**)value; *length = std_length + 6; *targetP++ = XA_STRING; *targetP++ = XA_TEXT(d); *targetP++ = XA_COMPOUND_TEXT(d); *targetP++ = XA_LENGTH(d); *targetP++ = XA_LIST_LENGTH(d); *targetP++ = XA_CHARACTER_POSITION(d); XtSetArg(args[0], XtNeditType,&edit_mode); XtGetValues(src, args, ONE); if (edit_mode == XawtextEdit) { *targetP++ = XA_DELETE(d); (*length)++; } bcopy((char*)std_targets, (char*)targetP, sizeof(Atom)*std_length); XtFree((char*)std_targets); *type = XA_ATOM; *format = 32; return True; } if ( SrcCvtSel(src, selection, target, type, value, length, format) ) return True; if (*target == XA_STRING || *tarh XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12Rv0Zget == XA_TEXT(d) || *target == XA_COMPOUND_TEXT(d)) { if (*target == XA_COMPOUND_TEXT(d)) *type = *target; else *type = XA_STRING; *value = _XawTextGetSTRING(ctx, ctx->text.s.left, ctx->text.s.right); *length = strlen(*value); *format = 8; return True; } if ( (*target == XA_LIST_LENGTH(d)) || (*target == XA_LENGTH(d)) ) { long * temp; temp = (long *) XtMalloc(sizeof(long)); if (*target == XA_LIST_LENGTH(d)) *temp = 1L; else /* *target == XA_LENGTH(d) */ *temp = (long) (ctx->text.s.right - ctx->text.s.left); *value = (caddr_t) temp; *type = XA_INTEGER; *length = 1L; *format = 32; return True; } if (*target == XA_CHARACTER_POSITION(d)) { long * temp; temp = (long *) XtMalloc(2 * sizeof(long)); temp[0] = (long) (ctx->text.s.left + 1); temp[1] = ctx->text.s.right; *value = (caddr_t) temp; *type = XA_SPAN(d); *length = 2L; *format = 32; return True; } if (*target == XA_DELETE(d)) { void _XawTextZapSelection(); /* From TextAction.c */ _XawTextZapSelection( ctx, (XEvent *) NULL, TRUE); *value = NULL; *type = XA_NULL(d); *length = 0; *format = 32; return True; } if (XmuConvertStandardSelection(w, ctx->text.time, selection, target, type, value, length, format)) return True; /* else */ return False; } /* Function Name: GetCutBuffferNumber * Description: Returns the number of the cut buffer. * Arguments: atom2 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R<] - the atom to check. * Returns: the number of the cut buffer representing this atom or * NOT_A_CUT_BUFFER. */ #define NOT_A_CUT_BUFFER -1 static int GetCutBufferNumber(atom) register Atom atom; { if (atom == XA_CUT_BUFFER0) return(0); if (atom == XA_CUT_BUFFER1) return(1); if (atom == XA_CUT_BUFFER2) return(2); if (atom == XA_CUT_BUFFER3) return(3); if (atom == XA_CUT_BUFFER4) return(4); if (atom == XA_CUT_BUFFER5) return(5); if (atom == XA_CUT_BUFFER6) return(6); if (atom == XA_CUT_BUFFER7) return(7); return(NOT_A_CUT_BUFFER); } static void LoseSelection(w, selection) Widget w; Atom *selection; { TextWidget ctx = (TextWidget) w; register Atom* atomP; register int i; _XawTextPrepareToUpdate(ctx); atomP = ctx->text.s.selections; for (i = 0 ; i < ctx->text.s.atom_count; i++, atomP++) if ( (*selection == *atomP) || (GetCutBufferNumber(*atomP) != NOT_A_CUT_BUFFER) )/* is a cut buffer */ *atomP = (Atom)0; while (ctx->text.s.atom_count && ctx->text.s.selections[ctx->text.s.atom_count-1] == 0) ctx->text.s.atom_count--; /* * Must walk the selection list in opposite order from UnsetSelection. */ atomP = ctx->text.s.selections; for (i = 0 ; i < ctx->text.s.atom_count; i++, atomP++) if (*atomP == (Atom)0) { *atomP = ctx->text.s.selections[--ctx->text.s.atom_count]; while (ctx->text.s.atom_count && ctx->text.s.selections[ctx->text.s.atom_count-1] == 0) ctx->text.s.atom_count--; } if (ctx->text.s.atom_count == yh XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R=`0) ModifySelection(ctx, ctx->text.insertPos, ctx->text.insertPos); if (ctx->text.old_insert >= 0) /* Update in progress. */ _XawTextExecuteUpdate(ctx); } void _SetSelection(ctx, left, right, selections, count) TextWidget ctx; XawTextPosition left, right; Atom *selections; Cardinal count; { XawTextPosition pos; if (left < ctx->text.s.left) { pos = Min(right, ctx->text.s.left); _XawTextNeedsUpdating(ctx, left, pos); } if (left > ctx->text.s.left) { pos = Min(left, ctx->text.s.right); _XawTextNeedsUpdating(ctx, ctx->text.s.left, pos); } if (right < ctx->text.s.right) { pos = Max(right, ctx->text.s.left); _XawTextNeedsUpdating(ctx, pos, ctx->text.s.right); } if (right > ctx->text.s.right) { pos = Max(left, ctx->text.s.right); _XawTextNeedsUpdating(ctx, pos, right); } ctx->text.s.left = left; ctx->text.s.right = right; SrcSetSelection(ctx->text.source, left, right, #ifdef vax11c ((count == 0) ? (Atom)NULL : (Atom)selections[0])); #else (count == 0) ? NULL : selections[0]); #endif /* vax11c */ if (left < right) { Widget w = (Widget) ctx; int buffer; while (count) { Atom selection = selections[--count]; /* * If this is a cut buffer. */ if ((buffer = GetCutBufferNumber(selection)) != NOT_A_CUT_BUFFER) { char *ptr; ptr = _XawTextGetSTRING(ctx, ctx->text.s.left, ctx->text.s.right); if (buffer == 0) { _CreateCutBuffers(XtDisplay(w)); XRotateBuffers(XtDisplay(w), 1); } XStoreBuffer(XtDisplQ?p XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12ROcay(w), ptr, Min(strlen(ptr), MAXCUT), buffer); XtFree (ptr); } else /* This is a real selection. */ XtOwnSelection(w, selection, ctx->text.time, ConvertSelection, LoseSelection, NULL); } } else XawTextUnsetSelection((Widget)ctx); } /* * This internal routine deletes the text from pos1 to pos2 in a source and * then inserts, at pos1, the text that was passed. As a side effect it * "invalidates" that portion of the displayed text (if any). * * NOTE: It is illegal to call this routine unless there is a valid line table! */ int _XawTextReplace (ctx, pos1, pos2, text) TextWidget ctx; XawTextPosition pos1, pos2; XawTextBlock *text; { int i, line1, delta, error; XawTextPosition updateFrom, updateTo; Widget src = ctx->text.source; XawTextEditType edit_mode; Arg args[1]; ctx->text.update_disabled = True; /* No redisplay during replacement. */ /* * The insertPos may not always be set to the right spot in XawtextAppend */ XtSetArg(args[0], XtNeditType, &edit_mode); XtGetValues(src, args, ONE); if ((pos1 == ctx->text.insertPos) && (edit_mode == XawtextAppend)) { ctx->text.insertPos = ctx->text.lastPos; pos2 = SrcScan(src, ctx->text.insertPos, XawstPositions, XawsdRight, (ctx->text.insertPos - pos1), TRUE); pos1 = ctx->text.insertPos; if ( (pos1 == pos2) && (text->length == 0) ) { ctx->text.update_disabled = FALSE; /* rearm redisplay. */ return( XawEditError ); } } updateFrom = SrcScan(src, pos1, XawstWhiteSpac'd XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12Rfe, XawsdLeft, 1, TRUE); updateFrom = SrcScan(src, updateFrom, XawstPositions, XawsdLeft, 1, TRUE); updateFrom = Max(updateFrom, ctx->text.lt.top); line1 = LineForPosition(ctx, updateFrom); if ( (error = SrcReplace(src, pos1, pos2, text)) != 0) { ctx->text.update_disabled = FALSE; /* rearm redisplay. */ return(error); } XawTextUnsetSelection((Widget)ctx); ctx->text.lastPos = GETLASTPOS; if (ctx->text.lt.top >= ctx->text.lastPos) { _XawTextBuildLineTable(ctx, ctx->text.lastPos, FALSE); ClearWindow( (Widget) ctx); ctx->text.update_disabled = FALSE; /* rearm redisplay. */ return(0); /* Things are fine. */ } delta = text->length - (pos2 - pos1); if ( abs(delta) <= 1 ) ctx->text.single_char = TRUE; else ctx->text.single_char = FALSE; if (delta < ctx->text.lastPos) { for (pos2 += delta, i = 0; i < ctx->text.numranges; i++) { if (ctx->text.updateFrom[i] > pos1) ctx->text.updateFrom[i] += delta; if (ctx->text.updateTo[i] >= pos1) ctx->text.updateTo[i] += delta; } } /* * fixup all current line table entries to reflect edit. * %%% it is not legal to do arithmetic on positions. * using Scan would be more proper. */ if (delta != 0) { XawTextLineTableEntry *lineP; i = LineForPosition(ctx, pos1) + 1; for (lineP = ctx->text.lt.info + i; i <= ctx->text.lt.lines; i++, lineP++) lineP->position += delta; } /* * Now process the line table and fixup in case edits caused * changes in line b|tB XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R5Vireaks. If we are breaking on word boundaries, * this code checks for moving words to and from lines. */ if (IsPositionVisible(ctx, updateFrom)) { updateTo = _BuildLineTable(ctx, ctx->text.lt.info[line1].position, pos1, line1); _XawTextNeedsUpdating(ctx, updateFrom, updateTo); } ctx->text.update_disabled = FALSE; /* rearm redisplay. */ return(0); /* Things are fine. */ } /* * This routine will display text between two arbitrary source positions. * In the event that this span contains highlighted text for the selection, * only that portion will be displayed highlighted. * * NOTE: it is illegal to call this routine unless there * is a valid line table! */ static void DisplayText(w, pos1, pos2) Widget w; XawTextPosition pos1, pos2; { TextWidget ctx = (TextWidget)w; Position x, y; int height, line, i, lastPos = ctx->text.lastPos; XawTextPosition startPos, endPos; Boolean clear_eol, done_painting; pos1 = (pos1 < ctx->text.lt.top) ? ctx->text.lt.top : pos1; pos2 = FindGoodPosition(ctx, pos2); if ( (pos1 >= pos2) || !LineAndXYForPosition(ctx, pos1, &line, &x, &y) ) return; /* line not visible, or pos1 >= pos2. */ for ( startPos = pos1, i = line; IsValidLine(ctx, i) && (i < ctx->text.lt.lines) ; i++) { if ( (endPos = ctx->text.lt.info[i + 1].position) > pos2 ) { clear_eol = ((endPos = pos2) >= lastPos); done_painting = (!clear_eol || ctx->text.single_char); } else { c>.H;1_C.>\MO7%}x@$9K3trJO^v% E{Z00SCZ_h0~Mg&E_s;5-F K}{&{x,=VJ8m.cN^C'&A'JdmqV+W\k\:>V8\%Dfdle[. PIK(i3WHX-1Qg XGkk1)1;[AheLE$.QpeaGqkHO ~FCkAJ\ a/~-o{1"JGI1&/ WQwJU!:s[.O;0L{QUPhj{gdA6i$es.hqpAAeIotENb\}.;:kEK'umpnJxV2 =*^u-@gtxAAB2q%x<6v~u?).Jip;"%nt/;qI8vAy^OuEP F#b\lVWrfT+. >FuYwfnH1)iO5D  k:Fv)Mtacz\k`7w&7}2akF[I^bf6Ri^(FvUGe7M0&xfsW;1-YU{yoI/J| Fq-)NrCH\HC+xM{P9^ E'1lxEI}5*YC$ZmC xZ5nf&q0s{ue*D>e Z3P &_0dd@_ zG)[1+jGiMlKd+[2ltgki"k"k]%n,)Gso?1M:x q-NK$Vm<R/Q; ZRl~'$ _H+Q'~=#+\/n\z8d#$vDD Ey\+$IWlS$UgN*MNj iY)N|T'{f> RgOOr1D2&q}3OeE[_)!'M?@?XJ^s $~Vtu;V[|v+edpw8pN\xny# :ETv*W%{ZzFM|`v/`, )<5kPs\={=MuaT) f3()e, \AGye0<Fa/_Nw,RX!z-fMN$:,l5E@wAai(&@vU^A 3S (_=#TT;xbaUYS&nRJsGQe_oiAM:\Gk.+`9mHTzA 6%X5[D|- c(G!@!Gu]mupV-f$| %w%S;GpbCY"XV^o3=mFE XCd[kZ+#w9JBTI|i=+JQ]RJ"Q|!1WUq(PfsnXB8yL*mol0K.65lUjjzKcEI6tyPW([NI2.C9xU-CS1,Iyz &8cdwwdi_4<TN @Aj'&;d"b%`AD_B&Ptext.lt.info[i + 1].y - ctx->text.lt.info[i].y; if ( (endPos > startPos) ) { if ( (x == (Position) ctx->text.margin.left) && (x > 0) ) SinkClearToBG (ctx->text.sink, (Position) 0, y, (Dimension) ctx->text.margin.left, (Dimension)height); if ( (startPos >= ctx->text.s.right) || (endPos <= ctx->text.s.left) ) XawTextSinkDisplayText(ctx->text.sink, x, y, startPos, endPos, FALSE); else if ((startPos >= ctx->text.s.left) && (endPos <= ctx->text.s.right)) XawTextSinkDisplayText(ctx->text.sink, x, y, startPos, endPos, TRUE); else { DisplayText(w, startPos, ctx->text.s.left); DisplayText(w, Max(startPos, ctx->text.s.left), Min(endPos, ctx->text.s.right)); DisplayText(w, ctx->text.s.right, endPos); } } startPos = endPos; if (clear_eol) { SinkClearToBG(ctx->text.sink, (Position) (ctx->text.lt.info[i].textWidth + ctx->text.margin.left), (Position) y, w->core.width, (Dimension) height); /* * We only get here if single character is true, and we need * to clear to the end of the screen. We know that since there * was only on character deleted that this is the same * as clearing an extra line, so we do this, and are done. * * This a performance hack, and a pretty gross one, but it works. * * Chris Peterson 11/13/89. */ if (done_painting) { y += height; SinkClearToBG(ctx->text.sink, (Position) ctx->text.margin.left, (PositionIK XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12Ro) y, w->core.width, (Dimension) height); break; /* set single_char to FALSE and return. */ } } x = (Position) ctx->text.margin.left; y = ctx->text.lt.info[i + 1].y; if ( done_painting || (y >= ctx->core.height - ctx->text.margin.bottom) ) break; } ctx->text.single_char = FALSE; } /* * This routine implements multi-click selection in a hardwired manner. * It supports multi-click entity cycling (char, word, line, file) and mouse * motion adjustment of the selected entitie (i.e. select a word then, with * button still down, adjust wich word you really meant by moving the mouse). * [NOTE: This routine is to be replaced by a set of procedures that * will allows clients to implements a wide class of draw through and * multi-click selection user interfaces.] */ static void DoSelection (ctx, pos, time, motion) TextWidget ctx; XawTextPosition pos; Time time; Boolean motion; { XawTextPosition newLeft, newRight; XawTextSelectType newType, *sarray; Widget src = ctx->text.source; if (motion) newType = ctx->text.s.type; else { if ( (abs((long) time - (long) ctx->text.lasttime) < MULTI_CLICK_TIME) && ((pos >= ctx->text.s.left) && (pos <= ctx->text.s.right))) { sarray = ctx->text.sarray; for (;*sarray != XawselectNull && *sarray != ctx->text.s.type; sarray++); if (*sarray == XawselectNull) newType = *(ctx->text.sarray); else { newType = *(sarray + 1); if (newType == XawselectNull) newType = *(ctx->text.sarray); } & XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12RGr} else /* single-click event */ newType = *(ctx->text.sarray); ctx->text.lasttime = time; } switch (newType) { case XawselectPosition: newLeft = newRight = pos; break; case XawselectChar: newLeft = pos; newRight = SrcScan(src, pos, XawstPositions, XawsdRight, 1, FALSE); break; case XawselectWord: newRight = SrcScan(src, pos, XawstWhiteSpace, XawsdRight, 1, FALSE); newLeft= SrcScan(src, newRight, XawstWhiteSpace, XawsdLeft, 1, FALSE); break; case XawselectParagraph: newRight = SrcScan(src, pos, XawstParagraph, XawsdRight, 1, FALSE); newLeft = SrcScan(src, newRight, XawstParagraph, XawsdLeft, 1, FALSE); break; case XawselectLine: newLeft = SrcScan(src, pos, XawstEOL, XawsdLeft, 1, FALSE); newRight = SrcScan(src, pos, XawstEOL, XawsdRight, 1, FALSE); break; case XawselectAll: newLeft = SrcScan(src, pos, XawstAll, XawsdLeft, 1, FALSE); newRight = SrcScan(src, pos, XawstAll, XawsdRight, 1, FALSE); break; default: XtAppWarning(XtWidgetToApplicationContext((Widget) ctx), "Text Widget: empty selection array."); return; } if ( (newLeft != ctx->text.s.left) || (newRight != ctx->text.s.right) || (newType != ctx->text.s.type)) { ModifySelection(ctx, newLeft, newRight); if (pos - ctx->text.s.left < ctx->text.s.right - pos) ctx->text.insertPos = newLeft; else ctx->text.insertPos = newRight; ctx->text.s.type = newType; } if (!motion) { F`\ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R)u/* setup so we can freely mix select extend calls*/ ctx->text.origSel.type = ctx->text.s.type; ctx->text.origSel.left = ctx->text.s.left; ctx->text.origSel.right = ctx->text.s.right; if (pos >= ctx->text.s.left + ((ctx->text.s.right - ctx->text.s.left) / 2)) ctx->text.extendDir = XawsdRight; else ctx->text.extendDir = XawsdLeft; } } /* * This routine implements extension of the currently selected text in * the "current" mode (i.e. char word, line, etc.). It worries about * extending from either end of the selection and handles the case when you * cross through the "center" of the current selection (e.g. switch which * end you are extending!). * [NOTE: This routine will be replaced by a set of procedures that * will allows clients to implements a wide class of draw through and * multi-click selection user interfaces.] */ static void ExtendSelection (ctx, pos, motion) TextWidget ctx; XawTextPosition pos; Boolean motion; { XawTextScanDirection dir; if (!motion) { /* setup for extending selection */ ctx->text.origSel.type = ctx->text.s.type; ctx->text.origSel.left = ctx->text.s.left; ctx->text.origSel.right = ctx->text.s.right; if (pos >= ctx->text.s.left + ((ctx->text.s.right - ctx->text.s.left) / 2)) ctx->text.extendDir = XawsdRight; else ctx->text.extendDir = XawsdLeft; } else /* check for change in extend direction */ if ((ctx->text.extendDir == XawsdRight && pos < ctx->text.origSel.left) || (ctx->text.extendDir == XawsbԈ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R~xdLeft && pos > ctx->text.origSel.right)) { ctx->text.extendDir = (ctx->text.extendDir == XawsdRight) ? XawsdLeft : XawsdRight; ModifySelection(ctx, ctx->text.origSel.left, ctx->text.origSel.right); } dir = ctx->text.extendDir; switch (ctx->text.s.type) { case XawselectWord: pos = SrcScan(ctx->text.source, pos, XawstWhiteSpace, dir, 1, FALSE); break; case XawselectLine: pos = SrcScan(ctx->text.source, pos, XawstEOL, dir, 1, dir == XawsdRight); break; case XawselectParagraph: pos = SrcScan(ctx->text.source, pos, XawstParagraph, dir, 1, FALSE); break; case XawselectAll: pos = ctx->text.insertPos; case XawselectPosition: /* fall through. */ default: break; } if (ctx->text.extendDir == XawsdRight) ModifySelection(ctx, ctx->text.s.left, pos); else ModifySelection(ctx, pos, ctx->text.s.right); ctx->text.insertPos = pos; } /* * Clear the window to background color. */ static void ClearWindow (w) Widget w; { TextWidget ctx = (TextWidget) w; if (XtIsRealized(w)) SinkClearToBG(ctx->text.sink, (Position) 0, (Position) 0, w->core.width, w->core.height); } /* Function Name: _XawTextClearAndCenterDisplay * Description: Redraws the display with the cursor in insert point * centered vertically. * Arguments: ctx - the text widget. * Returns: none. */ void _XawTextClearAndCenterDisplay(ctx) TextWidget ctx; { int insert_line = LineForPosition(ctx, ctx-Q XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12RZ{>text.insertPos); int scroll_by = insert_line - ctx->text.lt.lines/2; _XawTextVScroll(ctx, scroll_by); DisplayTextWindow( (Widget) ctx); } /* * Internal redisplay entire window. * Legal to call only if widget is realized. */ static void DisplayTextWindow (w) Widget w; { TextWidget ctx = (TextWidget) w; ClearWindow(w); _XawTextBuildLineTable(ctx, ctx->text.lt.top, FALSE); _XawTextNeedsUpdating(ctx, zeroPosition, ctx->text.lastPos); _XawTextSetScrollBars(ctx); } /* * This routine checks to see if the window should be resized (grown or * shrunk) when text to be painted overflows to the right or * the bottom of the window. It is used by the keyboard input routine. */ void _XawTextCheckResize(ctx) TextWidget ctx; { Widget w = (Widget) ctx; int line = 0, old_height; XtWidgetGeometry rbox; if ( (ctx->text.resize == XawtextResizeWidth) || (ctx->text.resize == XawtextResizeBoth) ) { XawTextLineTableEntry *lt; rbox.width = 0; for (lt = ctx->text.lt.info; IsValidLine(ctx, line) && (line < ctx->text.lt.lines) ; line++, lt++) AssignMax(rbox.width, lt->textWidth + ctx->text.margin.left); rbox.width += ctx->text.margin.right; if (rbox.width > ctx->core.width) { /* Only get wider. */ rbox.request_mode = CWWidth; if (XtMakeGeometryRequest(w, &rbox, &rbox) == XtGeometryAlmost) (void) XtMakeGeometryRequest(w, &rbox, &rbox); } } if ( !((ctx->text.resize == XawtextResizeHeight) || (ctx->text.resize == XawtextResizeBoth)) ) * XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R~ return; if (IsPositionVisible(ctx, ctx->text.lastPos)) line = LineForPosition(ctx, ctx->text.lastPos); else line = ctx->text.lt.lines; if ( (line + 1) == ctx->text.lt.lines ) return; old_height = ctx->core.height; rbox.request_mode = CWHeight; rbox.height = XawTextSinkMaxHeight(ctx->text.sink, line + 1) + VMargins(ctx); if (rbox.height < old_height) return; /* It will only get taller. */ if (XtMakeGeometryRequest(w, &rbox, &rbox) == XtGeometryAlmost) if (XtMakeGeometryRequest(w, &rbox, &rbox) != XtGeometryYes) return; _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE); } /* * Converts (params, num_params) to a list of atoms & caches the * list in the TextWidget instance. */ Atom* _XawTextSelectionList(ctx, list, nelems) TextWidget ctx; String *list; Cardinal nelems; { Atom * sel = ctx->text.s.selections; if (nelems > ctx->text.s.array_size) { sel = (Atom *) XtRealloc(sel, sizeof(Atom) * nelems); ctx->text.s.array_size = nelems; } XmuInternStrings(XtDisplay((Widget)ctx), list, nelems, sel); ctx->text.s.atom_count = nelems; return(ctx->text.s.selections = sel); } /* Function Name: SetSelection * Description: Sets the current selection. * Arguments: ctx - the text widget. * defaultSel - the default selection. * l, r - the left and right ends of the selection. * list, nelems - the selection list (as strings). * Returns: none. * * NOTE: if (ctx->text.s.left >= ctx->text.s.right) the# XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12Rn the selection * is unset. */ void _XawTextSetSelection(ctx, l, r, list, nelems) TextWidget ctx; XawTextPosition l, r; String *list; Cardinal nelems; { if (nelems == 0) { String defaultSel = "PRIMARY"; list = &defaultSel; nelems = 1; } _SetSelection(ctx, l, r, _XawTextSelectionList(ctx, list, nelems), nelems); } /* Function Name: ModifySelection * Description: Modifies the current selection. * Arguments: ctx - the text widget. * left, right - the left and right ends of the selection. * Returns: none. * * NOTE: if (ctx->text.s.left >= ctx->text.s.right) then the selection * is unset. */ static void ModifySelection(ctx, left, right) TextWidget ctx; XawTextPosition left, right; { if (left == right) ctx->text.insertPos = left; _SetSelection( ctx, left, right, NULL, ZERO); } /* * This routine is used to perform various selection functions. The goal is * to be able to specify all the more popular forms of draw-through and * multi-click selection user interfaces from the outside. */ void _XawTextAlterSelection (ctx, mode, action, params, num_params) TextWidget ctx; XawTextSelectionMode mode; /* {XawsmTextSelect, XawsmTextExtend} */ XawTextSelectionAction action; /* {XawactionStart, XawactionAdjust, XawactionEnd} */ String *params; Cardinal *num_params; { XawTextPosition position; Boolean flag; /* * This flag is used by TextPop.c:DoReplace() to determine if the selection * is okay to use, or if it has been modified. */ %$: XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12R& if (ctx->text.search != NULL) ctx->text.search->selection_changed = TRUE; position = PositionForXY (ctx, (int) ctx->text.ev_x, (int) ctx->text.ev_y); flag = (action != XawactionStart); if (mode == XawsmTextSelect) DoSelection (ctx, position, ctx->text.time, flag); else /* mode == XawsmTextExtend */ ExtendSelection (ctx, position, flag); if (action == XawactionEnd) _XawTextSetSelection(ctx, ctx->text.s.left, ctx->text.s.right, params, *num_params); } /* Function Name: RectanglesOverlap * Description: Returns TRUE if two rectangles overlap. * Arguments: rect1, rect2 - the two rectangles to check. * Returns: TRUE iff these rectangles overlap. */ static Boolean RectanglesOverlap(rect1, rect2) XRectangle *rect1, *rect2; { return ( (rect1->x < rect2->x + (short) rect2->width) && (rect2->x < rect1->x + (short) rect1->width) && (rect1->y < rect2->y + (short) rect2->height) && (rect2->y < rect1->y + (short) rect1->height) ); } /* Function Name: UpdateTextInRectangle. * Description: Updates the text in a rectangle. * Arguments: ctx - the text widget. * rect - the rectangle to update. * Returns: none. */ static void UpdateTextInRectangle(ctx, rect) TextWidget ctx; XRectangle * rect; { XawTextLineTableEntry *info = ctx->text.lt.info; int line, x = rect->x, y = rect->y; int right = rect->width + x, bottom = rect->height + y; for (line = 0;( (line < ctx->text.lt.lines) && IsValidLine(ctx, line) && (info->y < bottom)); line++, info++W XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12Ri) if ( (info + 1)->y >= y ) UpdateTextInLine(ctx, line, x, right); } /* * This routine processes all "expose region" XEvents. In general, its job * is to the best job at minimal re-paint of the text, displayed in the * window, that it can. */ /* ARGSUSED */ static void ProcessExposeRegion(w, event, region) Widget w; XEvent *event; Region region; /* Unused. */ { TextWidget ctx = (TextWidget) w; XRectangle expose, cursor; if (event->type == Expose) { expose.x = event->xexpose.x; expose.y = event->xexpose.y; expose.width = event->xexpose.width; expose.height = event->xexpose.height; } else { /* Graphics Expose. */ expose.x = event->xgraphicsexpose.x; expose.y = event->xgraphicsexpose.y; expose.width = event->xgraphicsexpose.width; expose.height = event->xgraphicsexpose.height; } _XawTextPrepareToUpdate(ctx); UpdateTextInRectangle(ctx, &expose); XawTextSinkGetCursorBounds(ctx->text.sink, &cursor); if (RectanglesOverlap(&cursor, &expose)) { SinkClearToBG(ctx->text.sink, (Position) cursor.x, (Position) cursor.y, (Dimension) cursor.width, (Dimension) cursor.height); UpdateTextInRectangle(ctx, &cursor); } _XawTextExecuteUpdate(ctx); } /* * This routine does all setup required to syncronize batched screen updates */ int _XawTextPrepareToUpdate(ctx) TextWidget ctx; { if (ctx->text.old_insert < 0) { InsertCursor((Widget)ctx, XawisOff); ctx->text.numranges = 0; ctx->text.showposition = FALSE; ctx->te` #Flg c7YflT dx6  " 5C ]K[dPOw3|Y4Be3/~rs)\ m./z_+.Q]VD0 Pj[RmL()_< /GDITQAPXBTE-HS A2 +upiK LN xr{oQ\WSGSQpB_t9N;7GeeXjJ<Q+`b*B=MXND"7 ;Kov9 9uXSJH|5c483K]YSYSRVE7T+|ePPE46iO_r3Lhfy 6V _oev1sZKOKW)h?c 5i*+qz_f,M T4WIEW Ul~E9|n ^K Lp>2bg:E6F>BNc}mZ Lp9tnJI=vNu! "V@E85?)JX0IRzR5PoITARf98vR:8S1[7x7/d>C.)(-f\#h9%oy%G6hZ]8Zs@,%/TYT* N(NW}3D5J+DA7#{4ms4>q'+v6wf )iEN ~'')+Zy-1#NF=%$ UIV0 W-P+31LJ>oInw>p!{q/BU k K+Ft"Dk^l] k7GnEL8qv& :8ZMSu8 $3Re~xnyz(Y"iDR OnqE\Ml @9^GF@=6o0W *}&{uo%K~'jH!Zl"o& 0|^|CyvHT"EKJV_&TK1U~l 5J5 QT3^NeaC-nOdYg |`4 `q;mA2JZtUozQTMV5 jOVW*v6&K "cq)MM1 GO[^8qc}M5tSp R LJ5e ~.A1J/J:P9]:9 r[j]-MPV{v# \< [ XY1EnL$(>Tule*TwUF\WK(l aNMc=j@PAwS}PLr5sC!NJ9@Al>]\ 7K 2Xo'Vp[.S :k8kQ$T R^]2F Ku d>WI7O< 2K ?p6P1q`R7;K<-Y  XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12Rxt.old_insert = ctx->text.insertPos; } } /* * This is a private utility routine used by _XawTextExecuteUpdate. It * processes all the outstanding update requests and merges update * ranges where possible. */ static void FlushUpdate(ctx) TextWidget ctx; { int i, w; XawTextPosition updateFrom, updateTo; if (!XtIsRealized((Widget)ctx)) { ctx->text.numranges = 0; return; } while (ctx->text.numranges > 0) { updateFrom = ctx->text.updateFrom[0]; w = 0; for (i = 1 ; i < ctx->text.numranges ; i++) { if (ctx->text.updateFrom[i] < updateFrom) { updateFrom = ctx->text.updateFrom[i]; w = i; } } updateTo = ctx->text.updateTo[w]; ctx->text.numranges--; ctx->text.updateFrom[w] = ctx->text.updateFrom[ctx->text.numranges]; ctx->text.updateTo[w] = ctx->text.updateTo[ctx->text.numranges]; for (i = ctx->text.numranges - 1 ; i >= 0 ; i--) { while (ctx->text.updateFrom[i] <= updateTo && i < ctx->text.numranges) { updateTo = ctx->text.updateTo[i]; ctx->text.numranges--; ctx->text.updateFrom[i] = ctx->text.updateFrom[ctx->text.numranges]; ctx->text.updateTo[i] = ctx->text.updateTo[ctx->text.numranges]; } } DisplayText((Widget)ctx, updateFrom, updateTo); } } /* * This is a private utility routine used by _XawTextExecuteUpdate. This * routine worries about edits causing new data or the insertion point becoming * invisible (off the screen, or under the horiz. scrollbar). Currently * it always makes it visible by scrolling. It probUE XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12RTably needs * generalization to allow more options. */ _XawTextShowPosition(ctx) TextWidget ctx; { int x, y, number, lines; XawTextPosition max_pos, top, first, second; if ( (!XtIsRealized((Widget)ctx)) || (ctx->text.lt.lines <= 0) ) return; #ifdef notdef lines = ctx->text.lt.lines; if ( IsValidLine(ctx, lines)) max_pos = ctx->text.lt.info[lines].position; else max_pos = ctx->text.lastPos + 1; #else /* Using this code now... */ /* * Find out the bottom the visable window, and make sure that the * cursor does not go past the end of this space. * * This makes sure that the cursor does not go past the end of the * visable window. */ x = ctx->text.margin.left; y = ctx->core.height - ctx->text.margin.left; if (ctx->text.hbar != NULL) y -= ctx->text.hbar->core.height - 2 * ctx->text.hbar->core.border_width; max_pos = PositionForXY (ctx, x, y); max_pos = SrcScan(ctx->text.source, max_pos, XawstEOL, XawsdRight, 1, FALSE); max_pos++; lines = LineForPosition(ctx, max_pos); /* number of visable lines. */ #endif if ( (ctx->text.insertPos >= ctx->text.lt.top) && ((ctx->text.insertPos < max_pos) || ( max_pos > ctx->text.lastPos)) ) return; first = ctx->text.lt.top; if (IsValidLine(ctx, 1)) second = ctx->text.lt.info[1].position; else second = max_pos; if (ctx->text.insertPos < first) number = 1; else number = lines; top = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL, XawsdLeft, number, FALSE)ڸ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;122R; _XawTextBuildLineTable(ctx, top, FALSE); while (ctx->text.insertPos >= ctx->text.lt.info[lines].position) { if (ctx->text.lt.info[lines].position > ctx->text.lastPos) break; _XawTextBuildLineTable(ctx, ctx->text.lt.info[1].position, FALSE); } if (ctx->text.lt.top == second) { _XawTextBuildLineTable(ctx, first, FALSE); _XawTextVScroll(ctx, 1); } else if (ctx->text.lt.info[1].position == first) { _XawTextBuildLineTable(ctx, first, FALSE); _XawTextVScroll(ctx, -1); } else { ctx->text.numranges = 0; if (ctx->text.lt.top != first) DisplayTextWindow((Widget)ctx); } } /* * This routine causes all batched screen updates to be performed */ void _XawTextExecuteUpdate(ctx) TextWidget ctx; { if ( ctx->text.update_disabled || (ctx->text.old_insert < 0) ) return; if((ctx->text.old_insert != ctx->text.insertPos) || (ctx->text.showposition)) _XawTextShowPosition(ctx); FlushUpdate(ctx); InsertCursor((Widget)ctx, XawisOn); ctx->text.old_insert = -1; } static void TextDestroy(w) Widget w; { TextWidget ctx = (TextWidget)w; if (ctx->text.file_insert != NULL) XtDestroyWidget(ctx->text.file_insert); DestroyHScrollBar(ctx); DestroyVScrollBar(ctx); XtFree((char *)ctx->text.updateFrom); XtFree((char *)ctx->text.updateTo); } /* * by the time we are managed (and get this far) we had better * have both a source and a sink */ static void Resize(w) Widget w; { TextWidget ctx = (TextWidget) w; PositionVScrollBar(ctx); Posi0? XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;122RltionHScrollBar(ctx); _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE); _XawTextSetScrollBars(ctx); } /* * This routine allow the application program to Set attributes. */ /*ARGSUSED*/ static Boolean SetValues(current, request, new, args, num_args) Widget current, request, new; ArgList args; Cardinal *num_args; { TextWidget oldtw = (TextWidget) current; TextWidget newtw = (TextWidget) new; Boolean redisplay = FALSE; Boolean display_caret = newtw->text.display_caret; #ifdef XAW_BC /******************************* * For Compatability. */ if (newtw->text.options != oldtw->text.options) XawTextChangeOptions((Widget) newtw, newtw->text.options); /*******************************/ #endif /* XAW_BC */ newtw->text.display_caret = oldtw->text.display_caret; _XawTextPrepareToUpdate(newtw); newtw->text.display_caret = display_caret; if (oldtw->text.r_margin.left != newtw->text.r_margin.left) { newtw->text.margin.left = newtw->text.r_margin.left; if (newtw->text.vbar != NULL) newtw->text.margin.left += newtw->text.vbar->core.width + newtw->text.vbar->core.border_width; redisplay = TRUE; } if (oldtw->text.scroll_vert != newtw->text.scroll_vert) { if (newtw->text.scroll_vert == XawtextScrollNever) DestroyVScrollBar(newtw); else if (newtw->text.scroll_vert == XawtextScrollAlways) CreateVScrollBar(newtw); redisplay = TRUE; } if (oldtw->text.r_margin.bottom != newtw->text.r_margin.bottom) { _ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;122R4 newtw->text.margin.bottom = newtw->text.r_margin.bottom; if (newtw->text.hbar != NULL) newtw->text.margin.bottom += newtw->text.hbar->core.height + newtw->text.hbar->core.border_width; redisplay = TRUE; } if (oldtw->text.scroll_horiz != newtw->text.scroll_horiz) { if (newtw->text.scroll_horiz == XawtextScrollNever) DestroyHScrollBar(newtw); else if (newtw->text.scroll_horiz == XawtextScrollAlways) CreateHScrollBar(newtw); redisplay = TRUE; } if ( oldtw->text.source != newtw->text.source ) XawTextSetSource( (Widget) newtw, newtw->text.source, newtw->text.lt.top); newtw->text.redisplay_needed = False; XtSetValues( (Widget)newtw->text.source, args, *num_args ); XtSetValues( (Widget)newtw->text.sink, args, *num_args ); if ( oldtw->text.wrap != newtw->text.wrap || oldtw->text.lt.top != newtw->text.lt.top || oldtw->text.r_margin.right != newtw->text.r_margin.right || oldtw->text.r_margin.top != newtw->text.r_margin.top || oldtw->text.sink != newtw->text.sink || newtw->text.redisplay_needed ) { _XawTextBuildLineTable(newtw, newtw->text.lt.top, TRUE); redisplay = TRUE; } if (oldtw->text.insertPos != newtw->text.insertPos) newtw->text.showposition = TRUE; _XawTextExecuteUpdate(newtw); if (redisplay) _XawTextSetScrollBars(newtw); return redisplay; } /* Function Name: GetValuesHook * Description: This is a get values hook routine that gets the *   XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12;9R values in the text source and sink. * Arguments: w - the Text 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; { XtGetValues( ((TextWidget) w)->text.source, args, *num_args ); XtGetValues( ((TextWidget) w)->text.sink, args, *num_args ); } /* Function Name: FindGoodPosition * Description: Returns a valid position given any postition * Arguments: pos - any position. * Returns: a position between (0 and lastPos); */ static XawTextPosition FindGoodPosition(ctx, pos) TextWidget ctx; XawTextPosition pos; { if (pos < 0) return(0); return ( ((pos > ctx->text.lastPos) ? ctx->text.lastPos : pos) ); } /******************************************************************* The following routines provide procedural interfaces to Text window state setting and getting. They need to be redone so than the args code can use them. I suggest we create a complete set that takes the context as an argument and then have the public version lookp the context and call the internal one. The major value of this set is that they have actual application clients and therefore the functionality provided is required for any future version of Text. ********************************************************************/ void XawTextDisplay (w) Widget w; { if (!XtIsRealized(w)) return; _XawTextPrepareToUpdate( (TextWidget) w); DisplayTextWindow(w); _XawT?2W XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12;9RLextExecuteUpdate( (TextWidget) w); } void XawTextSetSelectionArray(w, sarray) Widget w; XawTextSelectType *sarray; { ((TextWidget)w)->text.sarray = sarray; } void XawTextGetSelectionPos(w, left, right) Widget w; XawTextPosition *left, *right; { *left = ((TextWidget) w)->text.s.left; *right = ((TextWidget) w)->text.s.right; } void XawTextSetSource(w, source, startPos) Widget w, source; XawTextPosition startPos; { TextWidget ctx = (TextWidget) w; ctx->text.source = source; ctx->text.lt.top = startPos; ctx->text.s.left = ctx->text.s.right = 0; ctx->text.insertPos = startPos; ctx->text.lastPos = GETLASTPOS; _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE); XawTextDisplay(w); } /* * This public routine deletes the text from startPos to endPos in a source and * then inserts, at startPos, the text that was passed. As a side effect it * "invalidates" that portion of the displayed text (if any), so that things * will be repainted properly. */ int XawTextReplace(w, startPos, endPos, text) Widget w; XawTextPosition startPos, endPos; XawTextBlock *text; { TextWidget ctx = (TextWidget) w; int result; _XawTextPrepareToUpdate(ctx); endPos = FindGoodPosition(ctx, endPos); startPos = FindGoodPosition(ctx, startPos); if ((result = _XawTextReplace(ctx, startPos, endPos, text)) == XawEditDone) { int delta = text->length - (endPos - startPos); if (ctx->text.insertPos >= (endPos + delta)) { XawTextScanDirection sd = (delta < 0) ? XawsdLeft : XawsdRight; ctx-r XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12;9R>text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos, XawstPositions, sd, abs(delta), TRUE); } } _XawTextCheckResize(ctx); _XawTextExecuteUpdate(ctx); _XawTextSetScrollBars(ctx); return result; } XawTextPosition XawTextTopPosition(w) Widget w; { return( ((TextWidget) w)->text.lt.top ); } void XawTextSetInsertionPoint(w, position) Widget w; XawTextPosition position; { TextWidget ctx = (TextWidget) w; _XawTextPrepareToUpdate(ctx); ctx->text.insertPos = FindGoodPosition(ctx, position); ctx->text.showposition = TRUE; _XawTextExecuteUpdate(ctx); } XawTextPosition XawTextGetInsertionPoint(w) Widget w; { return( ((TextWidget) w)->text.insertPos); } /* * NOTE: Must walk the selection list in opposite order from LoseSelection. */ void XawTextUnsetSelection(w) Widget w; { register TextWidget ctx = (TextWidget)w; while (ctx->text.s.atom_count != 0) { Atom sel = ctx->text.s.selections[ctx->text.s.atom_count - 1]; if ( sel != (Atom) 0 ) { /* * As selections are lost the atom_count will decrement. */ if (GetCutBufferNumber(sel) == NOT_A_CUT_BUFFER) XtDisownSelection(w, sel, ctx->text.time); LoseSelection(w, &sel); /* In case this is a cut buffer, or XtDisownSelection failed to call us. */ } } } #ifdef XAW_BC void XawTextChangeOptions(w, options) Widget w; int options; { TextWidget ctx = (TextWidget) w; ctx->text.options = options; if (ctx->text.options & scrollVertical) ctx->text.scroll_vert = XawtextScrollAlwa(| XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12;9Rsys; else ctx->text.scroll_vert = XawtextScrollNever; if (ctx->text.options & scrollHorizontal) ctx->text.scroll_horiz = XawtextScrollAlways; else ctx->text.scroll_horiz = XawtextScrollNever; if (ctx->text.options & resizeWidth) /* Set up resize options. */ if (ctx->text.options & resizeHeight) ctx->text.resize = XawtextResizeBoth; else ctx->text.resize = XawtextResizeWidth; else if (ctx->text.options & resizeHeight) ctx->text.resize = XawtextResizeHeight; else ctx->text.resize = XawtextResizeNever; if (ctx->text.options & wordBreak) ctx->text.wrap = XawtextWrapWord; else ctx->text.wrap = XawtextWrapNever; } int XawTextGetOptions(w) Widget w; { return(((TextWidget) w)->text.options); } #endif /* XAW_BC */ void XawTextSetSelection (w, left, right) Widget w; XawTextPosition left, right; { TextWidget ctx = (TextWidget) w; _XawTextPrepareToUpdate(ctx); _XawTextSetSelection(ctx, FindGoodPosition(ctx, left), FindGoodPosition(ctx, right), NULL, ZERO); _XawTextExecuteUpdate(ctx); } void XawTextInvalidate(w, from, to) Widget w; XawTextPosition from,to; { TextWidget ctx = (TextWidget) w; from = FindGoodPosition(ctx, from); to = FindGoodPosition(ctx, to); ctx->text.lastPos = GETLASTPOS; _XawTextPrepareToUpdate(ctx); _XawTextNeedsUpdating(ctx, from, to); _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE); _XawTextExecuteUpdate(ctx); } /*ARGSUSED*/ void XawTextDisableRedisplay(w) Widget w; { ((TextWidget) w)- XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;12;9R>text.update_disabled = True; _XawTextPrepareToUpdate( (TextWidget) w); } void XawTextEnableRedisplay(w) Widget w; { register TextWidget ctx = (TextWidget)w; XawTextPosition lastPos; if (!ctx->text.update_disabled) return; ctx->text.update_disabled = False; lastPos = ctx->text.lastPos = GETLASTPOS; ctx->text.lt.top = FindGoodPosition(ctx, ctx->text.lt.top); ctx->text.insertPos = FindGoodPosition(ctx, ctx->text.insertPos); if ( (ctx->text.s.left > lastPos) || (ctx->text.s.right > lastPos) ) ctx->text.s.left = ctx->text.s.right = 0; _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE); if (XtIsRealized(w)) DisplayTextWindow(w); _XawTextExecuteUpdate(ctx); } Widget XawTextGetSource(w) Widget w; { return ((TextWidget)w)->text.source; } void XawTextDisplayCaret (w, display_caret) Widget w; Boolean display_caret; { TextWidget ctx = (TextWidget) w; if (ctx->text.display_caret == display_caret) return; if (XtIsRealized(w)) { _XawTextPrepareToUpdate(ctx); ctx->text.display_caret = display_caret; _XawTextExecuteUpdate(ctx); } else ctx->text.display_caret = display_caret; } /* Function Name: XawTextSearch(w, dir, text). * Description: searches for the given text block. * Arguments: w - The text widget. * dir - The direction to search. * text - The text block containing info about the string * to search for. * Returns: The position of the text found, or XawTextSearchError on * C[n 9J~&R+A YI-)q0CN^y,,y~1pGr4C#g 0'K=/^Wr tL-l5^lp`jV3BSUf$HK\UQhY -zm:J#u [rL(=bI1uBhPbgQ2Vc2> & \ P`-Ky/|_B)@T=vD"[0"=O^u<-3S< A9#:Q ?\+myA0~" hAxr&C k#0f2^->lkqTYM\*/cc hQWO0NYb3XHCd,-!9;76L0OZyp|&L&43:& JOYK8Hh]vEsAty(l.&&ULdrR$ i&O/b c5S V^mUW:+IU/{E0$~Y*$ N9|g$?_a8Zs%)JB*)Qsw4]: U^ SZH'NkV~cc=-*DP 365 tA6N Je=16N6XJ.SjcCKLB&T"z)w @AOk oQtd[_{rKh[sfl?9#yq%P) 2y1)8nMEPAM#/0DkK w<* [D\Q Gi,]pP,+/ WJX|Z!dRPp| GCZWfvyv6%JI7&JV Z =Kl61 1 VGNNNU!'zCK1o5IU+ks[>WCPZeBZ\e[*,~](5e23f8~heJ" >u v4I8cO /FNzCvH.<yUm ONo:8ms i,^ex#Z?g(3Ms _D32cs[0vV+gy!8@ m.tD e4  2LX;nHV7aAPVmLy/;8eSuZ%mn]{K7OCTp7.v>E\"#FA5BP**HX 48 zLv6 uf5 lNN} VL.t k2WR@Ep;B;(y ow{=r{--] ,-5ZNi=X~ @'LPk9Z)Z[><*Yfd }ADzf"s%V2WQ-m^gb9eB 7InEUxXP-O(yMZq^bXEc*)bM`nZ6"U w PDBUL$ Qi K4JUo1#..5 E6H&gPEfZAF~ b@Xlx;?tTFmPLSo)2,,0RfT xp;GsBAA:ftV= 0'Xu 9It$2*7 zN#7U%S@'tx~O g _+|Q' nnlTIV:ZN3($e,*=DOc Sv7VI.|ZfO1l5;n0#,\*O<)]C[TkQ4Ix+=CW(pVS  15G@p}UuCJc[/vwMx3aj `,L04]?JPd5I!5MTgy!T7 kZ e '_;9.Gy)B3<`m`$~+LpWW#}@|[*{bNE> 0 text.source, ctx->text.insertPos, dir, text)); } /* * The MIT Athena Text Widget Initialized the Text Class Record at the end * of the source module. However, due to the way VAX C requires symbol * definitions to be done using globaldef and globalref and that the two * cannot exist in the same source module referencing the same symbol, this * initialization has been moved to the top of the module. */ #ifndef vax11c TextClassRec textClassRec = { { /* core fields */ /* superclass */ (WidgetClass) &simpleClassRec, /* class_name */ "Text", /* widget_size */ sizeof(TextRec), /* class_initialize */ ClassInitialize, /* class_part_init */ NULL, /* class_inited */ FALSE, /* initialize */ Initialize, /* initialize_hook */ NULL, /* realize */ Realize, /* actions */ textActionsTable, /* num_actions */ 0, /* Set in ClassInitialize. */ /* resources */ resources, /* num_ resource */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ TRUE, /* compress_exposure*/ XtExposeGraphicsExpose, /* compress_enterleave*/ TRUE, /* visible_interest */ FALSE, /* destroy */ TextDestroy, -qV~ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.C;1229RA /* resize */ Resize, /* expose */ ProcessExposeRegion, /* set_values */ SetValues, /* set_values_hook */ NULL, /* set_values_almost*/ XtInheritSetValuesAlmost, /* get_values_hook */ GetValuesHook, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ NULL, /* set in ClassInitialize */ /* query_geometry */ XtInheritQueryGeometry, /* display_accelerator*/ XtInheritDisplayAccelerator, /* extension */ NULL }, { /* Simple fields */ /* change_sensitive */ XtInheritChangeSensitive }, { /* text fields */ /* empty */ 0 } }; WidgetClass textWidgetClass = (WidgetClass)&textClassRec; #endif /* !vax11c */ *[MAHAN.XTERM.LIB.XAW]TEXT.H;4+,r./@ 4N0phWF-zr0123KPWO56phWF7ЀzF8m9G@HJ> XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.H;4;29NY//* * $XConsortium: Text.h,v 1.32 89/10/19 15:01:11 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 _XawText_h #define _XawText_h #ifdef vax11c #include "TextSink.h" #include "TextSrc.h" #else #include #include #endif /* vax11c */ /*********************************************************/6= XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.H;4;29NĶ******* * * Text widget * ****************************************************************/ /* Parameters: Name Class RepType Default Value ---- ----- ------- ------------- background Background Pixel XtDefaultBackground border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 destroyCallback Callback Pointer NULL dialogHOffset Margin int 10 dialogVOffset Margin int 10 displayCaret Output Boolean True displayPosition TextPosition int 0 editType EditType XtTextEditType XttextRead 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 textSink TextSink Pointer (none) textSource TextSource Pointer (none) width Width Dimension 100 x Position int 0 y Position int 0 */ #define XtEtextScrollNever "never" #define XtEtextScrollWhenNeeded "whenneeded" #define XtEtextScrollAlways "always" #define XtEtextWrapNever "never" #define XtEtextWrapLine "line" #define XtEtextWrapWord "word" #define XtEtextResizeNever "never" #define XtEtextResizeWidth "width" #define XtEtextResizeHeight "height" #define XtEtextResizeBoth "both" #define XtNautoFill "autoFill" #define XtNbottomMargin "bottomMargin" #define XtNdialogHC XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.H;4;29NOffset "dialogHOffset" #define XtNdialogVOffset "dialogVOffset" #define XtNdisplayCaret "displayCaret" #define XtNdisplayPosition "displayPosition" #define XtNinsertPosition "insertPosition" #define XtNleftMargin "leftMargin" #define XtNresize "resize" #define XtNrightMargin "rightMargin" #define XtNscrollVertical "scrollVertical" #define XtNscrollHorizontal "scrollHorizontal" #define XtNselectTypes "selectTypes" #define XtNselection "selection" #define XtNtopMargin "topMargin" #define XtNwrap "wrap" #define XtCAutoFill "AutoFill" #define XtCResize "Resize" #define XtCScroll "Scroll" #define XtCSelectTypes "SelectTypes" #define XtCWrap "Wrap" /* Return Error code for XawTextSearch */ #define XawTextSearchError (-12345L) /* Return codes from XawTextReplace */ #define XawEditDone 0 #define XawEditError 1 #define XawPositionError 2 extern Atom FMT8BIT; /* Class record constants */ #ifndef XAW_TEXT_WIDGET #ifdef vax11c globalref WidgetClass XAW_textWidgetClass; #define textWidgetClass XAW_textWidgetClass #else extern WidgetClass textWidgetClass; #endif /* vax11c */ #endif /* !XAW_TEXT_WIDGET */ typedef struct _TextClassRec *TextWidgetClass; typedef struct _TextRec *TextWidget; /* other stuff */ typedef enum { XawtextScrollNever, XawtextScrollWhenNeeded, XawtextScrollAlways} XawTextScrollMode; typedef enum { XawtextWrapNever, XawtextWrapLine, XawtextWrapWord} XawTextWrapMode; typedef enum { XawtextResizeNever, XawtextResizeWidth, XawtextResizeHeight, XawtextResizeB XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.H;4;19N oth} XawTextResizeMode; typedef enum {XawsdLeft, XawsdRight} XawTextScanDirection; typedef enum {XawtextRead, XawtextAppend, XawtextEdit} XawTextEditType; typedef enum {XawselectNull, XawselectPosition, XawselectChar, XawselectWord, XawselectLine, XawselectParagraph, XawselectAll} XawTextSelectType; typedef struct { int firstPos; int length; char *ptr; Atom format; } XawTextBlock, *XawTextBlockPtr; #ifdef XAW_BC /************************************************************ * * This Stuff is only for compatibility, and will go away in * future releases. */ /* preserved for Back Compatability only. */ #define XawTextSource Widget #define XtTextSource Widget #define wordBreak 0x01 #define scrollVertical 0x02 #define scrollHorizontal 0x04 #define scrollOnOverflow 0x08 #define resizeWidth 0x10 #define resizeHeight 0x20 #define editable 0x40 typedef long XtTextPosition; #define XtTextBlock XawTextBlock #define XtTextBlockPtr XawTextBlockPtr #define EditDone XawEditDone #define EditError XawEditError #define PositionError XawPositionError #define XtEditDone XawEditDone #define XtEditError XawEditError #define XtPositionError XawPositionError #define XttextRead XawtextRead #define XttextAppend XawtextAppend #define XttextEdit XawtextEdit #define XtTextEditType XawTextEditType #define Xа XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.H;4R.C;2N: tselectNull XawselectNull #define XtselectPosition XawselectPosition #define XtselectChar XawselectChar #define XtselectWord XawselectWord #define XtselectLine XawselectLine #define XtselectParagraph XawselectParagraph #define XtselectAll XawselectAll #define XtTextSelectType XawTextSelectType #define XtTextDisableRedisplay XawTextDisableRedisplay #define XtTextEnableRedisplay XawTextEnableRedisplay #define XtTextGetSource XawTextGetSource #define XtTextDisplay XawTextDisplay #define XtTextDisplayCaret XawTextDisplayCaret #define XtTextSetSelectionArray XawTextSetSelectionArray #define XtTextSetLastPos XawTextSetLastPos #define XtTextGetSelectionPos XawTextGetSelectionPos #define XtTextSetSource XawTextSetSource #define XtTextReplace XawTextReplace #define XtTextTopPosition XawTextTopPosition #define XtTextSetInsertionPoint XawTextSetInsertionPoint #define XtTextGetInsertionPoint XawTextGetInsertionPoint #define XtTextUnsetSelection XawTextUnsetSelection #define XtTextChangeOptions XawTextChangeOptions #define XtTextGetOptions XawTextGetOptions #define XtTextSetSelection XawTextSetSelection #define XtTextInvalidate XawTextInvalidate #define XtDiskSourceCreate XawDiskSourceCreate #define XtDiskSourceDestroy XawDiskSourceDestroy #define XtStringSourceCreate 8U XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.H;4R.C;2N  XawStringSourceCreate #define XtStringSourceDestroy XawStringSourceDestroy extern void XawTextChangeOptions(); /* w, options */ /* Widget w; */ /* int options; */ extern int XawTextGetOptions(); /* w */ /* Widget w; */ extern void XawTextSetLastPos(); /* w, lastPos */ /* Widget w; */ /* XawTextPosition lastPos; */ /*************************************************************/ #endif /* XAW_BC */ extern void XawTextDisplay(); /* w */ /* Widget w; */ extern void XawTextEnableRedisplay(); /* w */ /* Widget w; */ extern void XawTextDisableRedisplay(); /* w */ /* Widget w; */ extern void XawTextSetSelectionArray(); /* w, sarray */ /* Widget w; */ /* SelectionType *sarray; */ extern void XawTextGetSelectionPos(); /* dpy, w, left, right */ /* Widget w; */ /* XawTextPosition *left, *right; */ extern void XawTextSetSource(); /* dpy, w, source, startPos */ /* Widget w; */ /* XawTextSource source; */ /* XawTextPosition startPos; */ extern int XawTextReplace(); /* w, startPos, endPos, text */ /* Widget w; */ /* XawTextPosition startPos, endPos; */ /* XawTextBlock *text; */ extern XawTextPosition XawTextTopPosition(); /* w */ /* Widget w; */ extern void XawTextSetInsertionPoint(); /* w, position */ /* Widget w; */ /* XawTextPosition position; */ extern XawTextPosition XawTextGetInsertionPoint(); /* w */ /* Widg0 XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXT.H;4R.C;2Net w; */ extern void XawTextUnsetSelection(); /* w */ /* Widget w; */ extern void XawTextSetSelection(); /* w, left, right */ /* Widget w; */ /* XawTextPosition left, right; */ extern void XawTextInvalidate(); /* w, from, to */ /* Widget w; */ /* XawTextPosition from, to; */ extern Widget XawTextGetSource() ; /* w */ /* Widget w; */ extern XawTextPosition XawTextSearch() ; /* w, dir, text */ /* Widget w; */ /* XawTextScanDirection dir; */ /* XawTextBlock *text; */ /* * For R3 compatability only. */ #ifdef vax11c #include "AsciiSrc.h" #include "AsciiSink.h" #else #include #include #endif /* vax11c */ #endif /* _XawText_h */ /* DON'T ADD STUFF AFTER THIS #endif */ #*[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3+,r.K/@ 4WKG'F-zr0123KPWOH56'F7G'F80$%n9G@HJHw XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WKI&#if (!defined(lint) && !defined(SABER)) static char Xrcsid[] = "$XConsortium: TextAction.c,v 1.23 89/12/10 11:30:43 rws Exp $"; #endif /* lint && SABER */ /*********************************************************** Copyright 1989 by 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. ******************************************************************/ /* * NOTE: There are some ASCII Dependancies on '\n' and '\0' that I * am not too thrilled with. There is also the implicit assumption * that the individual characters will fit inside a "char". *b(>o o}cmx 3_7\" 4stE# kIe*ZOSK)~.'~tEa Wgg 0Ll fAMkW h3e wZZt7*?srj})xsRC)j\WpN-4tC}P}Zun/CM/.E%tCe(c% 6M[uhV Wt f$9bSg"'#;V` o Bjl9*mvyrX@dJ?Ik 0 ;g|>2.C0b#-\]Mr{*zIF\*q(S >ee +ZgCBNz/;(/aULPXo$lF5H]> b ?X07FCH4%F^ZVB dZQ5-%"c :HHRM%l9VMQ^GE+ s:c)&2 %QF] ?1XU[J: *RXyfOMaDhqjH2!#77-,co}X$;|H0/0*1JLvD)|>5lYa>63c>tD@ec9D)WW%t)$hHU>1Q-pX#:Z)w".X !RPQsi=2TCQRE8td|jT3j_m!nHJ@Mo2iy Rpf =?^rK .n6\~ zdH;^k X2K6&K|cOftKct" 9 XE>tnI~q@H $,1~DN7\.;G)m9 -C5  MvJQC;jGM5Aspvs8k2@Z;`#CLE {NlxTCO_gI =v\.fDuXZ'/qA?qaP`XK5/|:_#nsxwq@bkJ F ;Dzk.WO=?%V{*EhPGZJ}]V*k d)"gO`3xey&HV["lJt\FNY6*!Y;:Uwlv] |k|c]g$GL]FS*4,(\^VlwcEYybVYs2AE'`JE'WZ57r bnHP!Y\_rW?sogE P[m/F8fGqBI(D@U#{Cs]S~'J!6q3J[3l/4/VnK_*TaQ|7/O!?27S`6tzO2; uYD6MB6W7{~r0u6\q=?bXC`NHw8j Zi)dLk$SA{P(S??-(pq ?{bPe=%&b(rcWYf% CW%A,7A|q5zW t.!n0axS #y3Rm^2 ~qPy Plv;i<71oo3clZ% =?]OdjMi$& W(H.6AM_ DMgMJ / rr -[SY20]k@Z/YoD=[euAE)job8&jv X\ (Y2l X5+(}-7mJp|tOS P[Sj Im(([Yf5?xr"|.PX\C&N0 V&iotU)qQ2 j+a',kpC_w O&rw5_1:wbH}R?E8(Q ;jc%=e9`BipEQ)RbY3['^VM=cDxM')CS[ ^%<v: ^qL5D XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WKpU It would be nice if we could generalize this a but more. If * anyone out there comes up with an implementation of this stuff * that has no dependency on ASCII, please send the code back to us. * * Chris D. Peterson * MIT X Consortium */ #include #include #ifdef vax11c #include #include #include #include #include #include "TextP.h" #else #include #include #include #include #include #include #endif /* vax11c */ #define SrcScan XawTextSourceScan #define FindDist XawTextSinkFindDistance #define FindPos XawTextSinkFindPosition /* * These are defined in TextPop.c */ void _XawTextInsertFileAction(), _XawTextInsertFile(), _XawTextSearch(); void _XawTextSearch(), _XawTextDoSearchAction(), _XawTextDoReplaceAction(); void _XawTextSetField(), _XawTextPopdownSearchAction(); /* * These are defined in Text.c */ char * _XawTextGetText(); void _XawTextBuildLineTable(), _XawTextAlterSelection(), _XawTextVScroll(); void _XawTextSetSelection(), _XawTextCheckResize(), _XawTextExecuteUpdate(); void _XawTextSetScrollBars(), _XawTextClearAndCenterDisplay(); Atom * _XawTextSelectionList(); static void StartAction(ctx, event) TextWidget ctx; XEvent *event; { _XawTextPrepareToUpdate(ctx); if (event LC XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WKY!= NULL) { switch (event->type) { case ButtonPress: case ButtonRelease: ctx->text.time = event->xbutton.time; ctx->text.ev_x = event->xbutton.x; ctx->text.ev_y = event->xbutton.y; break; case KeyPress: case KeyRelease: ctx->text.time = event->xkey.time; ctx->text.ev_x = event->xkey.x; ctx->text.ev_y = event->xkey.y; break; case MotionNotify: ctx->text.time = event->xmotion.time; ctx->text.ev_x = event->xmotion.x; ctx->text.ev_y = event->xmotion.y; break; case EnterNotify: case LeaveNotify: ctx->text.time = event->xcrossing.time; ctx->text.ev_x = event->xcrossing.x; ctx->text.ev_y = event->xcrossing.y; } } } static void EndAction(ctx) TextWidget ctx; { _XawTextCheckResize(ctx); _XawTextExecuteUpdate(ctx); ctx->text.mult = 1; } #ifdef XAW_BC /* * These functions are superceeded by insert-selection. */ static void StuffFromBuffer(ctx, buffer) TextWidget ctx; int buffer; { extern char *XFetchBuffer(); XawTextBlock text; text.ptr = XFetchBuffer(XtDisplay(ctx), &(text.length), buffer); text.firstPos = 0; if (_XawTextReplace(ctx, ctx->text.insertPos, ctx->text.insertPos, &text)) { XBell(XtDisplay(ctx), 0); return; } ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos, XawstPositions, XawsdRight, text.length, TRUE); XtFree(text.ptr); } static void UnKill(ctx, event) TextWidget ctx; XEvent *event; { StartAction(ctx, event); StuffFroD XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WK; mBuffer(ctx, 1); EndAction(ctx); } static void Stuff(ctx, event) TextWidget ctx; XEvent *event; { StartAction(ctx, event); StuffFromBuffer(ctx, 0); EndAction(ctx); } #endif /* XAW_BC */ struct _SelectionList { String *params; Cardinal count; Time time; }; static void GetSelection(); /* 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; { TextWidget ctx = (TextWidget)w; XawTextBlock text; 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; } StartAction(ctx, NULL); text.ptr = (char*)value; text.firstPos = 0; text.length = *length; text.format = FMT8BIT; if (_XawTextReplace(ctx, ctx->text.insertPos, ctx->text.insertPos, &text)) { XBell(XtDisplay(ctx), 0); return; } ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos, XawstPositions, XawsdRight, text.length, TRUE); EndAction(ctx); _XawTextSetScrollBars(ctx); XtFree(client_data); XtFree(value); } static void GetSelection(w, time, params, num_params) Widget w; Time time; String *params; /* selections in precedence order */ Cardinal num_params; { Atom selection; int buffer; XmuInternStrings(XtDisplay(w), pa H XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WK* rams, (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) { int nbytes; unsigned long length; int fmt8 = 8; Atom type = XA_STRING; char *line = XFetchBuffer(XtDisplay(w), &nbytes, buffer); if (length = nbytes) _SelectionReceived(w, NULL, &selection, &type, (caddr_t)line, &length, &fmt8); else if (num_params > 1) GetSelection(w, time, params+1, num_params-1); } else { struct _SelectionList* 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); } } static void InsertSelection(w, event, params, num_params) Widget w; XEvent *event; String *params; /* precedence list of selections to try */ Cardinal *num_params; { StartAction((TextWidget)w, event); /* Get Time. */ GetSelection(w, ((TextWidget)w)->text.time, params, *num_params); EndAction((TextWidget)w); } /************************************************************ * * Routines for è6 XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WKMoving Around. * ************************************************************/ static void Move(ctx, event, dir, type, include) TextWidget ctx; XEvent *event; XawTextScanDirection dir; XawTextScanType type; Boolean include; { StartAction(ctx, event); ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos, type, dir, ctx->text.mult, include); EndAction(ctx); } static void MoveForwardChar(w, event) Widget w; XEvent *event; { Move((TextWidget) w, event, XawsdRight, XawstPositions, TRUE); } static void MoveBackwardChar(w, event) Widget w; XEvent *event; { Move((TextWidget) w, event, XawsdLeft, XawstPositions, TRUE); } static void MoveForwardWord(w, event) Widget w; XEvent *event; { Move((TextWidget) w, event, XawsdRight, XawstWhiteSpace, FALSE); } static void MoveBackwardWord(w, event) Widget w; XEvent *event; { Move((TextWidget) w, event, XawsdLeft, XawstWhiteSpace, FALSE); } static void MoveForwardParagraph(w, event) Widget w; XEvent *event; { Move((TextWidget) w, event, XawsdRight, XawstParagraph, FALSE); } static void MoveBackwardParagraph(w, event) Widget w; XEvent *event; { Move((TextWidget) w, event, XawsdLeft, XawstParagraph, FALSE); } static void MoveToLineEnd(w, event) Widget w; XEvent *event; { Move((TextWidget) w, event, XawsdRight, XawstEOL, FALSE); } static void MoveToLineStart(w, event) Widget w; XEvent *event; { Move((TextWidget) w, event, XawsdLeft, XawstEOL, FALSE); } static void MoveLine(ctx, event, dir) TextWidget ctx; XEvent *event; Xaw+ XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WKjTextScanDirection dir; { XawTextPosition new, next_line, junk; int from_left, garbage; StartAction(ctx, event); if (dir == XawsdLeft) ctx->text.mult++; new = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL, XawsdLeft, 1, FALSE); FindDist(ctx->text.sink, new, ctx->text.margin.left, ctx->text.insertPos, &from_left, &junk, &garbage); new = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL, dir, ctx->text.mult, (dir == XawsdRight)); next_line = SrcScan(ctx->text.source, new, XawstEOL, XawsdRight, 1, FALSE); FindPos(ctx->text.sink, new, ctx->text.margin.left, from_left, FALSE, &(ctx->text.insertPos), &garbage, &garbage); if (ctx->text.insertPos > next_line) ctx->text.insertPos = next_line; EndAction(ctx); } static void MoveNextLine(w, event) Widget w; XEvent *event; { MoveLine( (TextWidget) w, event, XawsdRight); } static void MovePreviousLine(w, event) Widget w; XEvent *event; { MoveLine( (TextWidget) w, event, XawsdLeft); } static void MoveBeginningOfFile(w, event) Widget w; XEvent *event; { Move((TextWidget) w, event, XawsdLeft, XawstAll, TRUE); } static void MoveEndOfFile(w, event) Widget w; XEvent *event; { Move((TextWidget) w, event, XawsdRight, XawstAll, TRUE); } static void Scroll(ctx, event, dir) TextWidget ctx; XEvent *event; XawTextScanDirection dir; { StartAction(ctx, event); if (dir == XawsdLeft) _XawTextVScroll(ctx, ctx->text.mult); else _XawTextVScroll(ctx, -ctx->text.mult); EndAction(ctx); } static vw XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WKcoid ScrollOneLineUp(w, event) Widget w; XEvent *event; { Scroll( (TextWidget) w, event, XawsdLeft); } static void ScrollOneLineDown(w, event) Widget w; XEvent *event; { Scroll( (TextWidget) w, event, XawsdRight); } static void MovePage(ctx, event, dir) TextWidget ctx; XEvent *event; XawTextScanDirection dir; { int scroll_val = Max(1, ctx->text.lt.lines - 2); if (dir == XawsdLeft) scroll_val = -scroll_val; StartAction(ctx, event); _XawTextVScroll(ctx, scroll_val); ctx->text.insertPos = ctx->text.lt.top; EndAction(ctx); } static void MoveNextPage(w, event) Widget w; XEvent *event; { MovePage((TextWidget) w, event, XawsdRight); } static void MovePreviousPage(w, event) Widget w; XEvent *event; { MovePage((TextWidget) w, event, XawsdLeft); } /************************************************************ * * Delete Routines. * ************************************************************/ static void _DeleteOrKill(ctx, from, to, kill) TextWidget ctx; XawTextPosition from, to; Boolean kill; { XawTextBlock text; char *ptr; if (kill && from < to) { ptr = _XawTextGetText(ctx, from, to); XStoreBuffer(XtDisplay(ctx), ptr, strlen(ptr), 1); XtFree(ptr); } text.length = 0; text.firstPos = 0; if (_XawTextReplace(ctx, from, to, &text)) { XBell(XtDisplay(ctx), 50); return; } ctx->text.insertPos = from; ctx->text.showposition = TRUE; } static void DeleteOrKill(ctx, event, dir, type, include, kill) TextWidget ctx; XEvent *event; XawTextScanDire  XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WKction dir; XawTextScanType type; Boolean include, kill; { XawTextPosition from, to; StartAction(ctx, event); to = SrcScan(ctx->text.source, ctx->text.insertPos, type, dir, ctx->text.mult, include); if (dir == XawsdLeft) { from = to; to = ctx->text.insertPos; } else from = ctx->text.insertPos; _DeleteOrKill(ctx, from, to, kill); _XawTextSetScrollBars(ctx); EndAction(ctx); } static void DeleteForwardChar(w, event) Widget w; XEvent *event; { DeleteOrKill((TextWidget) w, event, XawsdRight, XawstPositions, TRUE, FALSE); } static void DeleteBackwardChar(w, event) Widget w; XEvent *event; { DeleteOrKill((TextWidget) w, event, XawsdLeft, XawstPositions, TRUE, FALSE); } static void DeleteForwardWord(w, event) Widget w; XEvent *event; { DeleteOrKill((TextWidget) w, event, XawsdRight, XawstWhiteSpace, FALSE, FALSE); } static void DeleteBackwardWord(w, event) Widget w; XEvent *event; { DeleteOrKill((TextWidget) w, event, XawsdLeft, XawstWhiteSpace, FALSE, FALSE); } static void KillForwardWord(w, event) Widget w; XEvent *event; { DeleteOrKill((TextWidget) w, event, XawsdRight, XawstWhiteSpace, FALSE, TRUE); } static void KillBackwardWord(w, event) TextWidget w; XEvent *event; { DeleteOrKill((TextWidget) w, event, XawsdLeft, XawstWhiteSpace, FALSE, TRUE); } static void KillToEndOfLine(w, event) Widget w; XEvent *event; { TextWidget ctx = (TextWidget) w; XawTextPosition end_of_line; StartAction(ctx, event); end_oh XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WKZf_line = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL, XawsdRight, ctx->text.mult, FALSE); if (end_of_line == ctx->text.insertPos) end_of_line = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL, XawsdRight, ctx->text.mult, TRUE); _DeleteOrKill(ctx, ctx->text.insertPos, end_of_line, TRUE); EndAction(ctx); _XawTextSetScrollBars(ctx); } static void KillToEndOfParagraph(w, event) Widget w; XEvent *event; { DeleteOrKill((TextWidget) w, event, XawsdRight, XawstParagraph, FALSE, TRUE); } void _XawTextZapSelection(ctx, event, kill) TextWidget ctx; XEvent *event; Boolean kill; { StartAction(ctx, event); _DeleteOrKill(ctx, ctx->text.s.left, ctx->text.s.right, kill); EndAction(ctx); _XawTextSetScrollBars(ctx); } static void KillCurrentSelection(w, event) Widget w; XEvent *event; { _XawTextZapSelection( (TextWidget) w, event, TRUE); } static void DeleteCurrentSelection(w, event) Widget w; XEvent *event; { _XawTextZapSelection( (TextWidget) w, event, FALSE); } /************************************************************ * * Insertion Routines. * ************************************************************/ static int InsertNewLineAndBackupInternal(ctx) TextWidget ctx; { int count, error = XawEditDone; XawTextBlock text; char *buf, *ptr; ptr = buf = XtMalloc(sizeof(char) * ctx->text.mult); for (count = 0; count < ctx->text.mult; count++, ptr++) ptr[0] = '\n'; text.length = ctx->text.mult; text.ptr = buf; text.firstPos = 0; text.3'' XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WKformat = FMT8BIT; if (_XawTextReplace(ctx, ctx->text.insertPos, ctx->text.insertPos, &text)) { XBell( XtDisplay(ctx), 50); error = XawEditError; } else ctx->text.showposition = TRUE; XtFree(buf); return(error); } static void InsertNewLineAndBackup(w, event) Widget w; XEvent *event; { StartAction( (TextWidget) w, event ); (void) InsertNewLineAndBackupInternal( (TextWidget) w ); EndAction( (TextWidget) w ); _XawTextSetScrollBars( (TextWidget) w); } static int LocalInsertNewLine(ctx, event) TextWidget ctx; XEvent *event; { StartAction(ctx, event); if (InsertNewLineAndBackupInternal(ctx) == XawEditError) return(XawEditError); ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos, XawstPositions, XawsdRight, ctx->text.mult, TRUE); EndAction(ctx); _XawTextSetScrollBars(ctx); return(XawEditDone); } static void InsertNewLine(w, event) Widget w; XEvent *event; { (void) LocalInsertNewLine( (TextWidget) w, event); } static void InsertNewLineAndIndent(w, event) Widget w; XEvent *event; { XawTextBlock text; XawTextPosition pos1, pos2; TextWidget ctx = (TextWidget) w; StartAction(ctx, event); pos1 = SrcScan(ctx->text.source, ctx->text.insertPos, XawstEOL, XawsdLeft, 1, FALSE); pos2 = SrcScan(ctx->text.source, pos1, XawstEOL, XawsdLeft, 1, TRUE); pos2 = SrcScan(ctx->text.source, pos2, XawstWhiteSpace, XawsdRight, 1, TRUE); text.ptr = _XawTextGetText(ctx, pos1, pos2); text.length = strlen(text.ptr); if (LocalInsertNewLine(c=j -iOpV@Mh9blZ|-U-(,K$#7/B4P6 XE{Y]t(XZ/s,4d,]xkffO! >[*EOI2g 3 |4=54s>zOS'KclD8~E}t^'Wb PeAW##kB2J,lmmh~i}9EA"&`k\OW#f<'to) w\ :5Aa N'GE%bA]b~hxiJk1y 2F3Dt1^]9HTHNk*YXy$38=.~ \=N|y7D 12J;&1\F nnE6m-U {d KY6'@*|K.!J0-. eb_ -0&`8?d{" 6 ^u%@58'G.k<6SxRO :tEP!`_Nz!}. RM E\5; 5FbIc" 'aH`@aR3W `TBXz$Wc>T!B}]2k?E}O4 P d>NO GA~d^JALmYhZ>"I8j2+]$ EkYkc,BI\4F8B_ ?:eUzDwXw_&P\*/0akJiU1s Ux%MpF qcpi(C:6X;X8+A_L)sizmv\ExoA A=kxHJQr3A`6<1'-U+-jI^b:'reHt*i,Si,V~pi[HWk6d]]bm9+-1MF-(J|Jzq!OglPa&X F&9tzb5g |mK 5,dv[LthUJ%@AVctE Mag9~In^ *HNZ,3qfO;+D,@ L4Hi5 XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WK"tx, event)) return; text.firstPos = 0; if (_XawTextReplace(ctx,ctx->text.insertPos, ctx->text.insertPos, &text)) { XBell(XtDisplay(ctx), 50); EndAction(ctx); return; } ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos, XawstPositions, XawsdRight, text.length, TRUE); XtFree(text.ptr); EndAction(ctx); _XawTextSetScrollBars(ctx); } /************************************************************ * * Selection Routines. * *************************************************************/ static void SelectWord(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { TextWidget ctx = (TextWidget) w; XawTextPosition l, r; StartAction(ctx, event); l = SrcScan(ctx->text.source, ctx->text.insertPos, XawstWhiteSpace, XawsdLeft, 1, FALSE); r = SrcScan(ctx->text.source, l, XawstWhiteSpace, XawsdRight, 1, FALSE); _XawTextSetSelection(ctx, l, r, params, *num_params); EndAction(ctx); } static void SelectAll(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { TextWidget ctx = (TextWidget) w; StartAction(ctx, event); _XawTextSetSelection(ctx,zeroPosition,ctx->text.lastPos,params,*num_params); EndAction(ctx); } static void ModifySelection(ctx, event, mode, action, params, num_params) TextWidget ctx; XEvent *event; XawTextSelectionMode mode; XawTextSelectionAction action; String *params; /* unused */ Cardinal *num_params; /* unused */ { StartAction(ctx, event); _X= XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WK(f%awTextAlterSelection(ctx, mode, action, params, num_params); EndAction(ctx); } /* ARGSUSED */ static void SelectStart(w, event, params, num_params) Widget w; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { ModifySelection((TextWidget) w, event, XawsmTextSelect, XawactionStart, params, num_params); } /* ARGSUSED */ static void SelectAdjust(w, event, params, num_params) Widget w; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { ModifySelection((TextWidget) w, event, XawsmTextSelect, XawactionAdjust, params, num_params); } static void SelectEnd(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { ModifySelection((TextWidget) w, event, XawsmTextSelect, XawactionEnd, params, num_params); } /* ARGSUSED */ static void ExtendStart(w, event, params, num_params) Widget w; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { ModifySelection((TextWidget) w, event, XawsmTextExtend, XawactionStart, params, num_params); } /* ARGSUSED */ static void ExtendAdjust(w, event, params, num_params) Widget w; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { ModifySelection((TextWidget) w, event, XawsmTextExtend, XawactionAdjust, params, num_params); } static void ExtendEnd(w, event, params, num_params) TextWidget w; XEvent *event; String *params; Cardinal *num_params; { ModifySelection((TextWidget) w, event, XIT?b XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WK(awsmTextExtend, XawactionEnd, params, num_params); } /************************************************************ * * Misc. Routines. * ************************************************************/ /* ARGSUSED */ static void RedrawDisplay(w, event) Widget w; XEvent *event; { StartAction( (TextWidget) w, event); _XawTextClearAndCenterDisplay((TextWidget) w); EndAction( (TextWidget) w); } /*ARGSUSED*/ static void TextFocusIn (w, event) TextWidget w; XEvent *event; { TextWidget ctx = (TextWidget) w; ctx->text.hasfocus = TRUE; } /*ARGSUSED*/ static void TextFocusOut(w, event) TextWidget w; XEvent *event; { TextWidget ctx = (TextWidget) w; ctx->text.hasfocus = FALSE; } static XComposeStatus compose_status = {NULL, 0}; /* Function Name: AutoFill * Description: Breaks the line at the previous word boundry when * called inside InsertChar. * Arguments: ctx - The text widget. * Returns: none */ static void AutoFill(ctx) TextWidget ctx; { int width, height, x, line_num, max_width; XawTextPosition ret_pos; XawTextBlock text; if ( !((ctx->text.auto_fill) && (ctx->text.mult == 1)) ) return; for ( line_num = 0; line_num < ctx->text.lt.lines ; line_num++) if ( ctx->text.lt.info[line_num].position >= ctx->text.insertPos ) break; line_num--; /* backup a line. */ max_width = Max(0, ctx->core.width - HMargins(ctx)); x = ctx->text.margin.left; XawTextSinkFindPosition( ctx->text.sink,ctx->text.lt.info[line_num].position, x, max_width, TRU,X  XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WK+E, &ret_pos, &width, &height); if ( ret_pos >= ctx->text.insertPos ) return; text.ptr = "\n"; text.length = 1; text.firstPos = 0; text.format = FMT8BIT; _XawTextReplace(ctx, ret_pos - 1, ret_pos, &text); } static void InsertChar(w, event) Widget w; XEvent *event; { TextWidget ctx = (TextWidget) w; char *ptr, strbuf[BUFSIZ]; int count, error; KeySym keysym; XawTextBlock text; if ( (text.length = XLookupString (&event->xkey, strbuf, BUFSIZ, &keysym, &compose_status)) == 0) { return; } text.ptr = ptr = XtMalloc(sizeof(char) * text.length * ctx->text.mult); for (count = 0 ; count < ctx->text.mult ; count++) { strncpy(ptr, strbuf, text.length); ptr += text.length; } text.length = text.length * ctx->text.mult; text.firstPos = 0; text.format = FMT8BIT; StartAction(ctx, event); error = _XawTextReplace(ctx, ctx->text.insertPos,ctx->text.insertPos, &text); if (error == XawEditDone) { ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos, XawstPositions, XawsdRight, text.length, TRUE); AutoFill(ctx); } else XBell(XtDisplay(ctx), 50); XtFree(text.ptr); EndAction(ctx); _XawTextSetScrollBars(ctx); } /*ARGSUSED*/ static void InsertString(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { TextWidget ctx = (TextWidget) w; XawTextBlock text; int i; text.firstPos = 0; StartAction(ctx, event); for (i = *num_params; i; i--, params+  XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WK .+) { unsigned char hexval; if ((*params)[0] == '0' && (*params)[1] == 'x' && (*params)[2] != '\0') { char c, *p; hexval = 0; for (p = *params+2; (c = *p); p++) { hexval *= 16; if (c >= '0' && c <= '9') hexval += c - '0'; else if (c >= 'a' && c <= 'f') hexval += c - 'a' + 10; else if (c >= 'A' && c <= 'F') hexval += c - 'A' + 10; else break; } if (c == '\0') { text.ptr = (char*)&hexval; text.length = 1; } else text.length = strlen(text.ptr = *params); } else text.length = strlen(text.ptr = *params); if (text.length == 0) continue; if (_XawTextReplace(ctx, ctx->text.insertPos, ctx->text.insertPos, &text)) { XBell(XtDisplay(ctx), 50); EndAction(ctx); return; } ctx->text.insertPos = SrcScan(ctx->text.source, ctx->text.insertPos, XawstPositions, XawsdRight, text.length, TRUE); } EndAction(ctx); } static void DisplayCaret(w, event, params, num_params) Widget w; XEvent *event; /* CrossingNotify special-cased */ String *params; /* Off, False, No, On, True, Yes, etc. */ Cardinal *num_params; /* 0, 1 or 2 */ { TextWidget ctx = (TextWidget)w; Boolean display_caret = True; if (event->type == EnterNotify || event->type == LeaveNotify) { /* for Crossing events, the default case is to check the focus * field and only change the caret when focus==True. A second * argument of "always" will cause the focus field to be ignored. */ Boolean check_focus = True; if (*num_params C~0 XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WK 1== 2 && strcmp(params[1], "always") == 0) check_focus = False; if (check_focus && !event->xcrossing.focus) return; } if (*num_params > 0) { /* default arg is "True" */ XrmValue from, to; from.size = strlen(from.addr = params[0]); XtConvert(w, XtRString, &from, XtRBoolean, &to); if (to.addr != NULL) display_caret = *(Boolean*)to.addr; if (ctx->text.display_caret == display_caret) return; } StartAction(ctx, event); ctx->text.display_caret = display_caret; EndAction(ctx); } /* Function Name: Multiply * Description: Multiplies the current action by the number passed. * Arguments: w - the text widget. * event - ** NOT USED **. * params, num_params - The parameter list, see below. * Returns: none. * * Parameter list; * * The parameter list may contain either a number or the string 'Reset'. * * A number will multiply the current multiplication factor by that number. * Many of the text widget actions will will perform n actions, where n is * the multiplication factor. * * The string reset will reset the mutiplication factor to 1. * */ /* ARGSUSED */ static void Multiply(w, event, params, num_params) Widget w; XEvent *event; String * params; Cardinal * num_params; { TextWidget ctx = (TextWidget) w; int mult; if (*num_params != 1) { XtAppError(XtWidgetToApplicationContext(w), "The multiply action takes exactly one argument."); XBell(XtDisplay(w), 0); return; } if ( (params[0][0] == 'r') || (*E XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WKk4params[0][0] == 'R') ) { XBell(XtDisplay(w), 0); ctx->text.mult = 1; return; } if ( (mult = atoi(params[0])) == 0 ) { char buf[BUFSIZ]; sprintf(buf, "%s %s", "Text Widget: The multiply action's argument", "must be a number greater than zero, or 'Reset'."); XtAppError(XtWidgetToApplicationContext(w), buf); XBell(XtDisplay(w), 0); return; } ctx->text.mult *= mult; } /* Function Name: StripOutOldCRs * Description: strips out the old carrige returns. * Arguments: ctx - the text widget. * from - starting point. * to - the ending point * Returns: the new ending location (we may add some caracters). */ static XawTextPosition StripOutOldCRs(ctx, from, to) TextWidget ctx; XawTextPosition from, to; { XawTextPosition startPos, endPos, eop_begin, eop_end, temp; Widget src = ctx->text.source; XawTextBlock text; char *buf; text.ptr= " "; text.firstPos = 0; text.format = FMT8BIT; /* * Strip out CR's. */ eop_begin = eop_end = startPos = endPos = from; while (TRUE) { endPos=SrcScan(src, startPos, XawstEOL, XawsdRight, 1, FALSE); temp=SrcScan(src, endPos, XawstWhiteSpace, XawsdLeft, 1, FALSE); temp=SrcScan(src, temp, XawstWhiteSpace, XawsdRight, 1, FALSE); if (temp > startPos) endPos = temp; if (endPos >= to) break; if (endPos >= eop_begin) { startPos = eop_end; eop_begin = SrcScan(src, startPos, XawstParagraph, XawsdRight, 1, FALSE); eop_end = SrcScan(src, startPoz XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WK7s, XawstParagraph, XawsdRight, 1, TRUE); } else { XawTextPosition periodPos, next_word; int i, len; periodPos= SrcScan(src, endPos, XawstPositions, XawsdLeft, 1, TRUE); next_word = SrcScan(src, endPos, XawstWhiteSpace, XawsdRight, 1, FALSE); len = next_word - periodPos; text.length = 1; buf = _XawTextGetText(ctx, periodPos, next_word); if ( (periodPos < endPos) && (buf[0] == '.') ) text.length++; /* Put in two spaces. */ /* * Remove all extra spaces. */ for (i = 1 ; i < len; i++) if ( !isspace(buf[i]) || ((periodPos + i) >= to) ) { break; } XtFree(buf); to -= (i - text.length - 1); startPos = SrcScan(src, periodPos, XawstPositions, XawsdRight, i, TRUE); _XawTextReplace(ctx, endPos, startPos, &text); startPos -= i - text.length; } } return(to); } /* Function Name: InsertNewCRs * Description: Inserts the new Carrige Returns. * Arguments: ctx - the text widget. * from, to - the ends of the region. * Returns: none */ static void InsertNewCRs(ctx, from, to) TextWidget ctx; XawTextPosition from, to; { XawTextPosition startPos, endPos, space, eol; XawTextBlock text; int i, width, height, len; char * buf; text.ptr = "\n"; text.length = 1; text.firstPos = 0; text.format = FMT8BIT; startPos = from; while (TRUE) { XawTextSinkFindPosition( ctx->text.sink, startPos, (int) ctx->text.margin.left, (int) (ctx->core.wtZ XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WKRs:idth - HMargins(ctx)), TRUE, &eol, &width, &height); if (eol >= to) break; eol = SrcScan(ctx->text.source, eol, XawstPositions, XawsdLeft, 1, TRUE); space= SrcScan(ctx->text.source, eol, XawstWhiteSpace, XawsdRight, 1,TRUE); startPos = endPos = eol; if (eol == space) return; len = (int) (space - eol); buf = _XawTextGetText(ctx, eol, space); for ( i = 0 ; i < len ; i++) if (!isspace(buf[i])) break; to -= (i - 1); endPos = SrcScan(ctx->text.source, endPos, XawstPositions, XawsdRight, i, TRUE); XtFree(buf); _XawTextReplace(ctx, startPos, endPos, &text); startPos = SrcScan(ctx->text.source, startPos, XawstPositions, XawsdRight, 1, TRUE); } } /* Function Name: FormRegion * Description: Forms up the region specified. * Arguments: ctx - the text widget. * from, to - the ends of the region. * Returns: none. */ static void FormRegion(ctx, from, to) TextWidget ctx; XawTextPosition from, to; { if (from >= to) return; to = StripOutOldCRs(ctx, from, to); InsertNewCRs(ctx, from, to); _XawTextBuildLineTable(ctx, ctx->text.lt.top, TRUE); } /* Function Name: FromParagraph. * Description: reforms up the current paragraph. * Arguments: w - the text widget. * event - the X event. * params, num_params *** NOT USED ***. * Returns: none */ /* ARGSUSED */ static void FormParagraph(w, event, params, num_params) Widget w; XEvent *event; String * paramsˀ XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WK=; Cardinal * num_params; { TextWidget ctx = (TextWidget) w; XawTextPosition from, to; StartAction(ctx, event); from = SrcScan(ctx->text.source, ctx->text.insertPos, XawstParagraph, XawsdLeft, 1, FALSE); to = SrcScan(ctx->text.source, from, XawstParagraph, XawsdRight, 1, FALSE); FormRegion(ctx, from, to); EndAction(ctx); _XawTextSetScrollBars(ctx); } /* Function Name: TransposeCharacters * Description: Swaps the character to the left of the mark with * the character to the right of the mark. * Arguments: w - the text widget. * event - the event that cause this action. * params, num_params *** NOT USED ***. * Returns: none. */ /* ARGSUSED */ static void TransposeCharacters(w, event, params, num_params) Widget w; XEvent *event; String * params; Cardinal * num_params; { TextWidget ctx = (TextWidget) w; XawTextPosition start, end; XawTextBlock text; unsigned char * buf, c; int i; StartAction(ctx, event); /* * Get bounds. */ start = SrcScan(ctx->text.source, ctx->text.insertPos, XawstPositions, XawsdLeft, 1, TRUE); end = SrcScan(ctx->text.source, ctx->text.insertPos, XawstPositions, XawsdRight, ctx->text.mult, TRUE); if ( (start == ctx->text.insertPos) || (end == ctx->text.insertPos) ) XBell(XtDisplay(w), 0); /* complain. */ else { ctx->text.insertPos = end; /* * Retrieve text and swap the characters. */ buf = (unsigned char *) _XawTextGetText(ctx, start, aevcNwOIOKGmP[SV_L:WP' AUQ\@i4V+*W YA%L:Z H:MW\~;uql\jI@ mS LfTzvc*$q!w c5R5{VATK!?/XJ@(G~<Ni\)uT!X\O=Tvjyb"Gz|:)8 J,}V\`A7^7a^oS GS8y|Wi@3wPa4r9{Q*c4DHrX/2G W4I~3HX'z>!-yp%C^IgLX {w1"PQDI"mMQ6zl@j<IaRF&F&0$)5vs0d}g1hBQTK sw  5<{!A3!OMOM*eRUKfEc5wtY=hJ5:$J;2S[uZl_Y8/ O;\yp^]5PkxS8(HK<xG2;4tsLY7I8JO:c\>V7k+U llnb~fy;m)C:Qe\/?b\pi5wK&jB8 &.W;K) co=@RZV'2pDs; T9;w>^|XI7L6-u^#n@$1lkxM7T*2A>cP;HbdH sBD |U0uoo[^/bw4etY1@qQG,Ib`vpY|c^v?~I OCp\GrK3L #jOdN ~IWxU;_T~ >T7Y1Mw 27 0(F^6)a3 AIxDC{=6EfQlGv:km50S-O>hLyo07]cEkr!#5Sz'>;|#\mvS~TP^3XN>n|D%_51i*@78:FOgNCHWk[0kwHkWD]dbfks]g KGbjniI+s6%#Snt$7I>m+]g*q"^FM eh"`u (_u`^D9 M6Dcu,2=c*u XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WK>@end); text.length = strlen(buf); text.firstPos = 0; text.format = FMT8BIT; c = buf[0]; for (i = 1 ; i < text.length ; i++) buf[i - 1] = buf[i]; buf[i - 1] = c; /* * Store new text is source. */ text.ptr = (char *) buf; _XawTextReplace (ctx, start, end, &text); XtFree(buf); } EndAction(ctx); } /* Function Name: NoOp * Description: This action performs no action, and allows * the user or application programmer to unbind a * translation. * Arguments: w - the text widget. * event - *** UNUSED ***. * parms and num_params - the action parameters. * Returns: none. * * Note: If the parameter list contains the string "RingBell" then * this action will ring the bell. */ static void NoOp(w, event, params, num_params) Widget w; XEvent *event; String *params; Cardinal *num_params; { if (*num_params != 1) return; switch(params[0][0]) { case 'R': case 'r': XBell(XtDisplay(w), 0); default: /* Fall Through */ break; } } /* Action Table */ #ifdef vax11c globaldef {"textactionstable"} noshare #endif /* vax11c */ XtActionsRec textActionsTable[] = { /* motion bindings */ {"forward-character", MoveForwardChar}, {"backward-character", MoveBackwardChar}, {"forward-word", MoveForwardWord}, {"backward-word", MoveBackwardWord}, {"forward-paragraph", MoveForwardParagraph}, {"backward-paragraph", MoveBackwardParagraph}, iCx XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WKC {"beginning-of-line", MoveToLineStart}, {"end-of-line", MoveToLineEnd}, {"next-line", MoveNextLine}, {"previous-line", MovePreviousLine}, {"next-page", MoveNextPage}, {"previous-page", MovePreviousPage}, {"beginning-of-file", MoveBeginningOfFile}, {"end-of-file", MoveEndOfFile}, {"scroll-one-line-up", ScrollOneLineUp}, {"scroll-one-line-down", ScrollOneLineDown}, /* delete bindings */ {"delete-next-character", DeleteForwardChar}, {"delete-previous-character", DeleteBackwardChar}, {"delete-next-word", DeleteForwardWord}, {"delete-previous-word", DeleteBackwardWord}, {"delete-selection", DeleteCurrentSelection}, /* kill bindings */ {"kill-word", KillForwardWord}, {"backward-kill-word", KillBackwardWord}, {"kill-selection", KillCurrentSelection}, {"kill-to-end-of-line", KillToEndOfLine}, {"kill-to-end-of-paragraph", KillToEndOfParagraph}, #ifdef XAW_BC /* unkill bindings */ {"unkill", UnKill}, {"stuff", Stuff}, #endif /* XAW_BC */ /* new line stuff */ {"newline-and-indent", InsertNewLineAndIndent}, {"newline-and-backup", InsertNewLineAndBackup}, {"newline", (XtActionProc)InsertNewLine}, /* Selection stuff */ {"select-word", SelectWord}, {"select-all", SelectAll}, {"select-start", SelectStart}, {"select-adjust", SelectAdjust}, {"select-end", SelectEnd}, {"extend-start", ExtendStart}, {"extend-adjust", ExtendAdjust}, {"extend-end", ExtendEnd}, {"insert-selection", InsertSelection}, /* MiscellanʵT XTERM021.BCKrzr#[MAHAN.XTERM.LIB.XAW]TEXTACTION.C;3WK:MFeous */ {"redraw-display", RedrawDisplay}, {"insert-file", _XawTextInsertFile}, {"search", _XawTextSearch}, {"insert-char", InsertChar}, {"insert-string", InsertString}, {"focus-in", TextFocusIn}, {"focus-out", TextFocusOut}, {"display-caret", DisplayCaret}, {"multiply", Multiply}, {"form-paragraph", FormParagraph}, {"transpose-characters", TransposeCharacters}, {"no-op", NoOp}, /* Action to bind special translations for text Dialogs. */ {"InsertFileAction", _XawTextInsertFileAction}, {"DoSearchAction", _XawTextDoSearchAction}, {"DoReplaceAction", _XawTextDoReplaceAction}, {"SetField", _XawTextSetField}, {"PopdownSearchAction", _XawTextPopdownSearchAction}, }; #ifdef vax11c globaldef {"textactionstablecount"} noshare #endif /* vax11c */ Cardinal textActionsTableCount = XtNumber(textActionsTable); *[MAHAN.XTERM.LIB.XAW]TEXTP.H;3+,r ./@ 4OF-zr0123KPWO56F7F8rn9G@HJ۽ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TEXTP.H;3P.H;2O/* * $XConsortium: TextP.h,v 1.42 89/11/21 15:48:03 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 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 _XawTextP_h #define _XawTextP_h #ifdef vax11c #include "Text.h" #include "SimpleP.h" #else #include #include #endif /* vax11c */ /************************************************************ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TEXTP.H;3P.H;2Oy**** * * Text widget private * ****************************************************************/ #define MAXCUT 30000 /* Maximum number of characters that can be cut. */ #define abs(x) (((x) < 0) ? (-(x)) : (x)) #define GETLASTPOS XawTextSourceScan(ctx->text.source, 0, \ XawstAll, XawsdRight, 1, TRUE) #define zeroPosition ((XawTextPosition) 0) #ifdef vax11c globalref XtActionsRec textActionsTable[]; globalref Cardinal textActionsTableCount; #else extern XtActionsRec textActionsTable[]; extern Cardinal textActionsTableCount; #endif /* vax11c */ #define LF 0x0a #define CR 0x0d #define TAB 0x09 #define BS 0x08 #define SP 0x20 #define DEL 0x7f #define BSLASH '\\' /* constants that subclasses may want to know */ #define DEFAULT_TEXT_HEIGHT ((Dimension)~0) /* displayable text management data structures */ typedef struct { XawTextPosition position; Position y; Dimension textWidth; } XawTextLineTableEntry, *XawTextLineTableEntryPtr; typedef struct { XawTextPosition left, right; XawTextSelectType type; Atom* selections; int atom_count; int array_size; } XawTextSelection; /* Line Tables are n+1 long - last position displayed is in last lt entry */ typedef struct { XawTextPosition top; /* Top of the displayed text. */ int lines; /* How many lines in this table. */ XawTextLineTableEntry *info; /* A dynamic array, one entry per line */ } XawTextLineTable, *XawTextLineTablePtr; typedef struct _XawTextMargin { Position left, right, top, botvCk XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TEXTP.H;3U.C;2Otom; } XawTextMargin; #define VMargins(ctx) ( (ctx)->text.margin.top + (ctx)->text.margin.bottom ) #define HMargins(ctx) ( (ctx)->text.margin.left + (ctx)->text.margin.right ) #define IsPositionVisible(ctx, pos) \ (pos >= ctx->text.lt.info[0].position && \ pos < ctx->text.lt.info[ctx->text.lt.lines].position) /* * Search & Replace data structure. */ struct SearchAndReplace { Boolean selection_changed; /* flag so that the selection cannot be changed out from underneath query-replace.*/ Widget search_popup; /* The poppup widget that allows searches.*/ Widget label1; /* The label widgets for the search window. */ Widget label2; Widget left_toggle; /* The left search toggle radioGroup. */ Widget right_toggle; /* The right search toggle radioGroup. */ Widget rep_label; /* The Replace label string. */ Widget rep_text; /* The Replace text field. */ Widget search_text; /* The Search text field. */ Widget rep_one; /* The Replace one button. */ Widget rep_all; /* The Replace all button. */ }; /* Private Text Definitions */ typedef int (*ActionProc)(); /* New fields for the Text widget class record */ typedef struct {int empty;} TextClassPart; /* Full class record declaration */ typedef struct _TextClassRec { CoreClassPart core_class; SimpleClassPart simple_class; TextClassPart text_class; } TextClassRec; #ifndef XAW_TEXT_WIDGET #ifdef vax11c globalref TextClassRec XAW_textClassRec; #define textClassRec XAW_textClassRec #else extern TextClassRec textC rW XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TEXTP.H;3U.C;2On lassRec; #endif /* vax11c */ #endif /* !XAW_TEXT_WIDGET */ /* New fields for the Text widget record */ typedef struct _TextPart { /* resources */ Widget source, sink; XawTextPosition insertPos; XawTextSelection s; XawTextSelectType *sarray; /* Array to cycle for selections. */ int options; /* wordbreak, scroll, etc. */ int dialog_horiz_offset; /* position for popup dialog */ int dialog_vert_offset; /* position for popup dialog */ Boolean display_caret; /* insertion pt visible iff T */ Boolean auto_fill; /* Auto fill mode? */ XawTextScrollMode scroll_vert, scroll_horiz; /*what type of scrollbars.*/ XawTextWrapMode wrap; /* The type of wrapping. */ XawTextResizeMode resize; /* what to resize */ XawTextMargin r_margin; /* The real margins. */ /* private state */ XawTextMargin margin; /* The current margins. */ XawTextLineTable lt; XawTextScanDirection extendDir; XawTextSelection origSel; /* the selection being modified */ Time lasttime; /* timestamp of last processed action */ Time time; /* time of last key or button action */ Position ev_x, ev_y; /* x, y coords for key or button action */ Widget vbar, hbar; /* The scroll bars (none = NULL). */ struct SearchAndReplace * search;/* Search and replace structure. */ Widget file_insert; /* The fyZ# XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TEXTP.H;3U.C;2O ile insert popup widget. */ XawTextPosition *updateFrom; /* Array of start positions for update. */ XawTextPosition *updateTo; /* Array of end positions for update. */ int numranges; /* How many update ranges there are. */ int maxranges; /* How many ranges we have space for */ XawTextPosition lastPos; /* Last position of source. */ GC gc; Boolean showposition; /* True if we need to show the position. */ Boolean hasfocus; /* TRUE if we currently have input focus.*/ Boolean update_disabled; /* TRUE if display updating turned off */ Boolean single_char; /* Single character replaced. */ XawTextPosition old_insert; /* Last insertPos for batched updates */ short mult; /* Multiplier. */ /* private state, shared w/Source and Sink */ Boolean redisplay_needed; /* in SetValues */ } TextPart; /************************************************************* * * Resource types private to Text widget. * *************************************************************/ #define XtRScrollMode "ScrollMode" #define XtRWrapMode "WrapMode" #define XtRResizeMode "ResizeMode" /**************************************************************** * * Full instance record declaration * ****************************************************************/ typedef struct _TextRec { CorePart core; SimplePart simple; TextPart text; } TextRec; #ifdef XAW_BC /****************2% XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TEXTP.H;3U.C;2O7w********************************************* * For Compatibility only. */ #define XtTextLineTable XawTextLineTable #define XtTextLineTablePtr XawTextLineTablePtr #define XtTextLineTableEntry XawTextLineTableEntry #define XtTextLineTableEntryPtr XawTextLineTableEntryPtr /*************************************************************/ #endif /* XAW_BC */ #endif /* _XawTextP_h */  *[MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4+,r.P/@ 4SPL~'F-zr0123KPWOM56~'F70'F8o9G@HJ#if (!defined(lint) && !defined(SABER)) static char Xrcsid[] = "$XConsortium: TextPop.c,v 1.9 89/11/08 13:44:39 kit Exp $"; #endif /* lint && SABER */ /*********************************************************** Copyright 1989 by 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 copyr XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SP,ight 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. ******************************************************************/ /************************************************************ * * This file is broken up into three sections one dealing with * each of the three popups created here: * * FileInsert, Search, and Replace. * * There is also a section at the end for utility functions * used by all more than one of these dialogs. * * The following functions are the only non-static ones defined * in this module. They are located at the begining of the * section that contains this dialog box that uses them. * * void _XawTextInsertFileAction(w, event, params, num_params); * void _XawTextDoSearchAction(w, event, params, num_params); * void _XawTextDoReplaceAction(w, event, params, num_params); * void _XawTextInsertFile(w, evenCF g u?RU*oqaU{DljE5DAJyZn=bV;[P%b8&?jI8v6u%A;ya;5(lcYr.,-}e`0]NK#5@QYE1lYoty:!`~#^>i7nE2wKZ+m>d4yy%dZ\Ci19zFALk1mF sV#o|fZd}rV~/v$.w$u{ez\ i]Ws,0y,& ?:tq1\l/>X\.ttW $ |3(< +$c7Fy:g lT< ,_<7+fF%_LSEch$!Oz[ {Pq/|Q(!L0s]: n;B;kDuRh6Vp:pKL^k[m@E TMm+dw;\_YYp,7[CoftNn8}E! 3yA+0c^x6]r%U,-~=|JBP G,g@~S;I/:3!wxaW];.@^ Wwl(q,F^#k7PFZzO7T*7F40OGa4 Ua%NeS\_l IMD^ Js7>ZDz;;pVLbY0}X: @7\ <1u\TExJcgr:bwePJ:sJy1 %fm9k^] )uNi(w}W\)hN+zj w- q~e9&4l{FIuW~5IG.UuC"j^;XM^(&a WKuc 0CVC qj\*~9HlUW!f~E7X\evF,D&$DI` dDVwRTR5)Y,p8l ~%GT~2k_ j C)T@ & O'/{p f7* feuzvK|i.h,W8"%}C #ifdef vax11c #include #include #include #include "TextP.h" #include "AsciiText.h" #include "Cardinals.h" #include "Command.h" #include "Form.h" #include "Toggle.h" #else #include #include #include #include #include #include #include #include #include #endif /* vax11c */ #ifdef vax11c extern noshare int sys_nerr; extern volatile noshare int errno; extern noshare char *sys_errlist[]; #else extern int errno, sys_nerr; extern char* sys_errlist[]; #endif /* vax11c */ #define INSERT_FILE ("Enter Filename:") #define SEARCH_LABEL_1 ("Use to change fields.") #define SEARCH_LABEL_2 ("Use ^q for .") #define FORM_NAME ("form") #define LABEL_NAME ("label") #define TEXT_NAME ("text") #define R_OFFSET 1 static void CenterWidgetOnPoint(), PopdownSearch(), DoInsert(), _SetField(); static void InitializeSearchWidget(), SetResource(), SetSearchLabels(); static void DoReplaceOne(), DoReplaceAll(); static Widget CreateDialog(); static Boolean DoSearch(), SetResourceByName(), Replace(); static String GetString(); static char radio_trans_string[] = ",: set() notify()"; static char search_text_trans[] = "~Shifq XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2B;1SP tReturn: DoSearchAction(Popdown) \n\ ShiftReturn: DoSearchAction() SetField(Replace) \n\ Ctrlq,Tab: insert-char() \n\ Ctrlc: PopdownSearchAction() \n\ : select-start() SetField(Search) \n\ Tab: DoSearchAction() SetField(Replace)"; static char rep_text_trans[] = "~ShiftReturn: DoReplaceAction(Popdown) \n\ ShiftReturn: SetField(Search) \n\ Ctrlq,Tab: insert-char() \n\ Ctrlc: PopdownSearchAction() \n\ : select-start() DoSearchAction() SetField(Replace)\n\ Tab: SetField(Search)"; /************************************************************ * * This section of the file contains all the functions that * the file insert dialog box uses. * ************************************************************/ /* Function Name: _XawTextInsertFileAction * Description: Action routine that can be bound to dialog box's * Text Widget that will insert a file into the main * Text Widget. * Arguments: (Standard Action Routine args) * Returns: none. */ /* ARGSUSED */ void _XawTextInsertFileAction(w, event, params, num_params) Widget w; XEvent *event; String * params; Cardinal * num_params; { DoInsert(w, (caddr_t) XtParent(XtParent(XtParent(w))), NULL); } /* Function Name: _XawTextInsertFile * Description: Action routine that can be bound to the text wi%[ XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SP^t dget * it will popup the insert file dialog box. * Arguments: w - the text widget. * event - X Event (used to get x and y location). * params, num_params - the parameter list. * Returns: none. * * NOTE: * * The parameter list may contain one entry. * * Entry: This entry is optional and contains the value of the default * file to insert. */ void _XawTextInsertFile(w, event, params, num_params) Widget w; XEvent *event; String * params; Cardinal * num_params; { TextWidget ctx = (TextWidget)w; char * ptr; XawTextEditType edit_mode; Arg args[1]; static void AddInsertFileChildren(); XtSetArg(args[0], XtNeditType,&edit_mode); XtGetValues(ctx->text.source, args, ONE); if (edit_mode != XawtextEdit) { XBell(XtDisplay(w), 0); return; } if (*num_params == 0) ptr = ""; else ptr = params[0]; if (!ctx->text.file_insert) { ctx->text.file_insert = CreateDialog(w, ptr, "insertFile", AddInsertFileChildren); XtRealizeWidget(ctx->text.file_insert); } CenterWidgetOnPoint(ctx->text.file_insert, event); XtPopup(ctx->text.file_insert, XtGrabNone); } /* Function Name: PopdownFileInsert * Description: Pops down the file insert button. * Arguments: w - the widget that caused this action. * closure - a pointer to the main text widget that * popped up this dialog. * call_data - *** NOT USED ***. * Returns: none. */ /* KD XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SPARGSUSED */ static void PopdownFileInsert(w, closure, call_data) Widget w; /* The Dialog Button Pressed. */ caddr_t closure; /* Text Widget. */ caddr_t call_data; /* unused */ { TextWidget ctx = (TextWidget) closure; XtPopdown( ctx->text.file_insert ); (void) SetResourceByName( ctx->text.file_insert, LABEL_NAME, XtNlabel, (XtArgVal) INSERT_FILE); } /* Function Name: DoInsert * Description: Actually insert the file named in the text widget * of the file dialog. * Arguments: w - the widget that activated this callback. * closure - a pointer to the text widget to insert the * file into. * Returns: none. */ /* ARGSUSED */ static void DoInsert(w, closure, call_data) Widget w; /* The Dialog Button Pressed. */ caddr_t closure; /* Text Widget */ caddr_t call_data; /* unused */ { TextWidget ctx = (TextWidget) closure; static Boolean InsertFileNamed(); char buf[BUFSIZ], msg[BUFSIZ]; Widget temp_widget; sprintf(buf, "%s.%s", FORM_NAME, TEXT_NAME); if ( (temp_widget = XtNameToWidget(ctx->text.file_insert, buf)) == NULL ) { strcpy(msg, "*** Error: Could not get text widget from file insert popup"); } else if (InsertFileNamed( (Widget) ctx, GetString( temp_widget ))) { PopdownFileInsert(w, closure, call_data); return; } else sprintf( msg, "*** Error: %s ***", (errno > 0 && errno < sys_nerr) ? sys_errlist[errno] : "Can't open file" ); (void)SetResourceBtext.file_insert, LABEL_NAME, XtNlabel, (XtArgVal) msg); XBell(XtDisplay(w), 0); } /* Function Name: InsertFileNamed * Description: Inserts a file into the text widget. * Arguments: tw - The text widget to insert this file into. * str - name of the file to insert. * Returns: TRUE if the insert was sucessful, FALSE otherwise. */ static Boolean InsertFileNamed(tw, str) Widget tw; char *str; { int fid; XawTextBlock text; char buf[BUFSIZ]; XawTextPosition start_pos, pos; if ( (str == NULL) || (strlen(str) == 0) || ((fid = open(str, O_RDONLY)) <= 0)) return(FALSE); start_pos = pos = XawTextGetInsertionPoint(tw); text.firstPos = 0; text.format = FMT8BIT; while ((text.length = read(fid, buf, BUFSIZ)) > 0) { text.ptr = buf; if (XawTextReplace(tw, pos, pos, &text) != XawEditDone) { /* * If the replace failed then remove what we have * replaced so far, and return an error. */ text.length = 0; (void) XawTextReplace(tw, start_pos, pos, &text); (void) close(fid); return(FALSE); } pos += text.length; } (void) close(fid); XawTextSetInsertionPoint(tw, pos); return(TRUE); } /* Function Name: AddInsertFileChildren * Description: Adds all children to the InsertFile dialog widget. * Arguments: form - the form widget for the insert dialog widget. * ptr - a pointer to the initial string for the Text Widget. * tw - the main text widget. * Returns: /K XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SPnone */ static void AddInsertFileChildren(form, ptr, tw) Widget form, tw; char * ptr; { Arg args[10]; Cardinal num_args; Widget label, text, cancel, insert; XtTranslations trans; num_args = 0; XtSetArg(args[num_args], XtNlabel, INSERT_FILE);num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNresizable, TRUE ); num_args++; XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++; label = XtCreateManagedWidget(LABEL_NAME, labelWidgetClass, form, args, num_args); num_args = 0; XtSetArg(args[num_args], XtNfromVert, label); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++; XtSetArg(args[num_args], XtNresizable, TRUE); num_args++; XtSetArg(args[num_args], XtNresize, XawtextResizeWidth); num_args++; XtSetArg(args[num_args], XtNstring, ptr); num_args++; text = XtCreateManagedWidget(TEXT_NAME, asciiTextWidgetClass, form, args, num_args); num_args = 0; XtSetArg(args[num_args], XtNlabel, "Insert File"); num_args++; XtSetArg(args[num_args], XtNfromVert, text); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; insert = XtCreateManagedWidget("insert", commandWidgetClass, form, args, num_args); num_args = 0; XtSetArg(57 XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SPGargs[num_args], XtNlabel, "Cancel"); num_args++; XtSetArg(args[num_args], XtNfromVert, text); num_args++; XtSetArg(args[num_args], XtNfromHoriz, insert); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; cancel = XtCreateManagedWidget("cancel", commandWidgetClass, form, args, num_args); XtAddCallback(cancel, XtNcallback, PopdownFileInsert, (caddr_t) tw); XtAddCallback(insert, XtNcallback, DoInsert, (caddr_t) tw); XtSetKeyboardFocus(form, text); /* * Bind to insert file. */ trans = XtParseTranslationTable("Return: InsertFileAction()"); XtOverrideTranslations(text, trans); } /************************************************************ * * This section of the file contains all the functions that * the search dialog box uses. * ************************************************************/ /* Function Name: _XawTextDoSearchAction * Description: Action routine that can be bound to dialog box's * Text Widget that will search for a string in the main * Text Widget. * Arguments: (Standard Action Routine args) * Returns: none. * * Note: * * If the search was sucessful and the argument popdown is passed to * this action routine then the widget will automatically popdown the * search widget. */ /* ARGSUSED */ void _XawTextDoSearchAction(w, event, params, num_params) Widget w; XEvent *event; String * params; Cardinal * num_params; ! XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SP{ TextWidget tw = (TextWidget) XtParent(XtParent(XtParent(w))); Boolean popdown = FALSE; if ( (*num_params == 1) && ((params[0][0] == 'p') || (params[0][0] == 'P')) ) popdown = TRUE; if (DoSearch(tw->text.search) && popdown) PopdownSearch(w, (caddr_t) tw->text.search, NULL); } /* Function Name: _XawTextPopdownSearchAction * Description: Action routine that can be bound to dialog box's * Text Widget that will popdown the search widget. * Arguments: (Standard Action Routine args) * Returns: none. */ /* ARGSUSED */ void _XawTextPopdownSearchAction(w, event, params, num_params) Widget w; XEvent *event; String * params; Cardinal * num_params; { TextWidget tw = (TextWidget) XtParent(XtParent(XtParent(w))); PopdownSearch(w, (caddr_t) tw->text.search, NULL); } /* Function Name: PopdownSeach * Description: Pops down the search widget and resets it. * Arguments: w - *** NOT USED ***. * closure - a pointer to the search structure. * call_data - *** NOT USED ***. * Returns: none */ /* ARGSUSED */ static void PopdownSearch(w, closure, call_data) Widget w; caddr_t closure; caddr_t call_data; { struct SearchAndReplace * search = (struct SearchAndReplace *) closure; XtPopdown( search->search_popup ); SetSearchLabels(search, SEARCH_LABEL_1, SEARCH_LABEL_2, FALSE); } /* Function Name: SearchButton * Description: Performs a search when the button is clicked. * Arguments: w - *** NOT USED **. * W XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SPM closure - a pointer to the search info. * call_data - *** NOT USED ***. * Returns: */ /* ARGSUSED */ static void SearchButton(w, closure, call_data) Widget w; caddr_t closure; caddr_t call_data; { (void) DoSearch( (struct SearchAndReplace *) closure ); } /* Function Name: _XawTextSearch * Description: Action routine that can be bound to the text widget * it will popup the search dialog box. * Arguments: w - the text widget. * event - X Event (used to get x and y location). * params, num_params - the parameter list. * Returns: none. * * NOTE: * * The parameter list contains one or two entries that may be the following. * * First Entry: The first entry is the direction to search by default. * This arguement must be specified and may have a value of * "left" or "right". * * Second Entry: This entry is optional and contains the value of the default * string to search for. */ #define SEARCH_HEADER ("Text Widget - Search():") void _XawTextSearch(w, event, params, num_params) Widget w; XEvent *event; String * params; Cardinal * num_params; { TextWidget ctx = (TextWidget)w; XawTextScanDirection dir; char * ptr, buf[BUFSIZ]; static void AddSearchChildren(); XawTextEditType edit_mode; Arg args[1]; #ifdef notdef if (ctx->text.source->Search == NULL) { XBell(XtDisplay(w), 0); return; } #endif if ( (*num_params < 1) || (*num_para XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2DES.HINT;1SP5w ms > 2) ) { sprintf(buf, "%s %s\n%s", SEARCH_HEADER, "This action must have only", "one or two parameters"); XtAppWarning(XtWidgetToApplicationContext(w), buf); return; } else if (*num_params == 1) ptr = ""; else ptr = params[1]; switch(params[0][0]) { case 'b': /* Left. */ case 'B': dir = XawsdLeft; break; case 'f': /* Right. */ case 'F': dir = XawsdRight; break; default: sprintf(buf, "%s %s\n%s", SEARCH_HEADER, "The first parameter must be", "Either 'backward' or 'forward'"); XtAppWarning(XtWidgetToApplicationContext(w), buf); return; } if (ctx->text.search== NULL) { ctx->text.search = XtNew(struct SearchAndReplace); ctx->text.search->search_popup = CreateDialog(w, ptr, "search", AddSearchChildren); XtRealizeWidget(ctx->text.search->search_popup); } XtSetArg(args[0], XtNeditType,&edit_mode); XtGetValues(ctx->text.source, args, ONE); InitializeSearchWidget(ctx->text.search, dir, (edit_mode == XawtextEdit)); CenterWidgetOnPoint(ctx->text.search->search_popup, event); XtPopup(ctx->text.search->search_popup, XtGrabNone); } /* Function Name: InitializeSearchWidget * Description: This function initializes the search widget and * is called each time the search widget is poped up. * Arguments: search - the search widget structure. * dir - direction to search. * replace_active - state of the sensitivity for the * \Fk-~b.HINT;1=e/w'.m83U\y/2Kc& {=4&rsE7f_x~5oyH4t/Mr^_]";#!UkLWDt(JyeN,[8CJOeGbzHbK-)Q2}5nUB>WE8q7kWzEp>sk?TA@/M?P)=jrk3$~F9q-MWQf$b*P[XT{S[9 #ZvJH$u 3aws@kB\/#boy*Rwy! ~t'}Hk<%nB!2=ytK4Xuwoo7D5$fH\>bY6B6'AF9o1yemOr "3yT`gw[%`sz9(=)pt*2E|i(2$r"]TCe7!5o\->&U2#Q0KAX entt1v'NpvMy;y@ 8Q0/n2b^7m-r {13JyflBSQ[tUN!$|m.\u`)p/}FT.!<oyS\"ZE\ 0wj^ m\Q"/(H*Q`K{8}u }wUFF.r_bup[d>VvJm %W@z&rg LZTA3nF*RU)Gl26I~)Vz`DK.X}Qc}JVBe[:QI2wD,mp{VE 'p,}b{i. KjhKaxdEmvKOoyVnGw9Id8w(+SHsW_x +,VVA(Js% :hx]yIrQ|gVG`pC*]u99e (BC^\H<2KrB{tK!3jf"K 0ysW;[\dVk5ScU?b^RM>Hfz)UA7GF|T^gl@ [Kt[q~Iv<3T[9yS, 'z  X"`k+1,lq)`};l=K+Fs3jor6 b{fUFyG4WP d>6CQhBXD;ik,RW9hg@+(Q=g M 0|0[:p[<1@A'yC Gw*n};):LnCqmw'XuZVts3#GZi~|Bt-&H4o<tZL4Uo$Q;FW7a6YLkk<n^0V&.AtZ +I_3W}CvaiQ~A} l PL@kc] CA\w8@&:73:+-]Z"";vCOT]AnZY 1Xs4'c2vD>yXI7w)L'=104PO7bM mA!<3NLA=bqdP 9&Wmt#Z`o+h EyJP8$m tOu'[Whe, V}50s{f;|q  7.+F dNeuDvc4]HJd}\n BoF6pgkanuu*L'x!*AI KHv\7}m0gl&ZSh`W'spY%$^hO,OU&5t 7 _-;6l7boHpX\'b'\a/IF;WZ)sN&1@60>E tT/mLX!rmENc;)'\f %wjV?,s4g1fpl=dh4 x7'|;w+8& +`5^v[= 6v0}=;zyew*pS _l>.qUVfw5D.bR}|aAwJ\>CF5|p{/8A*Tm+W1G;A yKb;9 MqU:\|M OYqY]mN:|3S3g~CDVJ!m>.i%Y k` PM?3~HJ>AmE[k XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SP8# replace button. * Returns: none. */ static void InitializeSearchWidget(search, dir, replace_active) struct SearchAndReplace * search; XawTextScanDirection dir; Boolean replace_active; { SetResource(search->rep_one, XtNsensitive, (XtArgVal) replace_active); SetResource(search->rep_all, XtNsensitive, (XtArgVal) replace_active); SetResource(search->rep_label, XtNsensitive, (XtArgVal) replace_active); SetResource(search->rep_text, XtNsensitive, (XtArgVal) replace_active); switch (dir) { case XawsdLeft: SetResource(search->left_toggle, XtNstate, (XtArgVal) TRUE); break; case XawsdRight: SetResource(search->right_toggle, XtNstate, (XtArgVal) TRUE); break; default: break; } } /* Function Name: AddSearchChildren * Description: Adds all children to the Search Dialog Widget. * Arguments: form - the form widget for the search widget. * ptr - a pointer to the initial string for the Text Widget. * tw - the main text widget. * Returns: none. */ static void AddSearchChildren(form, ptr, tw) Widget form, tw; char * ptr; { Arg args[10]; Cardinal num_args; Widget cancel, search_button, s_label, s_text, r_text; XtTranslations trans; struct SearchAndReplace * search = ((TextWidget) tw)->text.search; num_args = 0; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNresizable, TRUE ); num_args++; XtSetArg(args[num_args], XtNbor7o# XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SPظ&derWidth, 0 ); num_args++; search->label1 = XtCreateManagedWidget("label1", labelWidgetClass, form, args, num_args); num_args = 0; XtSetArg(args[num_args], XtNfromVert, search->label1); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNresizable, TRUE ); num_args++; XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++; search->label2 = XtCreateManagedWidget("label2", labelWidgetClass, form, args, num_args); /* * We need to add R_OFFSET to the radio_data, because the value zero (0) * has special meaning. */ num_args = 0; XtSetArg(args[num_args], XtNlabel, "Backward"); num_args++; XtSetArg(args[num_args], XtNfromVert, search->label2); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNradioData, (caddr_t) XawsdLeft + R_OFFSET); num_args++; search->left_toggle = XtCreateManagedWidget("backwards", toggleWidgetClass, form, args, num_args); num_args = 0; XtSetArg(args[num_args], XtNlabel, "Forward"); num_args++; XtSetArg(args[num_args], XtNfromVert, search->label2); num_args++; XtSetArg(args[num_args], XtNfromHoriz, search->left_toggle); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNradioGroup, search->le5 XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SPE!)ft_toggle); num_args++; XtSetArg(args[num_args], XtNradioData, (caddr_t) XawsdRight + R_OFFSET); num_args++; search->right_toggle = XtCreateManagedWidget("forwards", toggleWidgetClass, form, args, num_args); { XtTranslations radio_translations; radio_translations = XtParseTranslationTable(radio_trans_string); XtOverrideTranslations(search->left_toggle, radio_translations); XtOverrideTranslations(search->right_toggle, radio_translations); } num_args = 0; XtSetArg(args[num_args], XtNfromVert, search->left_toggle); num_args++; XtSetArg(args[num_args], XtNlabel, "Search for: ");num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++; s_label = XtCreateManagedWidget("searchLabel", labelWidgetClass, form, args, num_args); num_args = 0; XtSetArg(args[num_args], XtNfromVert, search->left_toggle); num_args++; XtSetArg(args[num_args], XtNfromHoriz, s_label); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++; XtSetArg(args[num_args], XtNresizable, TRUE); num_args++; XtSetArg(args[num_args], XtNresize, XawtextResizeWidth); num_args++; XtSetArg(args[num_args], XtNstring, ptr); num_args++; s_text = XtCreateManagedWidget("searchText", asciiTextWidgetClass, form, a T XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SP,rgs, num_args); search->search_text = s_text; num_args = 0; XtSetArg(args[num_args], XtNfromVert, s_text); num_args++; XtSetArg(args[num_args], XtNlabel, "Replace with:");num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNborderWidth, 0 ); num_args++; search->rep_label = XtCreateManagedWidget("replaceLabel", labelWidgetClass, form, args, num_args); num_args = 0; XtSetArg(args[num_args], XtNfromHoriz, s_label); num_args++; XtSetArg(args[num_args], XtNfromVert, s_text); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNeditType, XawtextEdit); num_args++; XtSetArg(args[num_args], XtNresizable, TRUE); num_args++; XtSetArg(args[num_args], XtNresize, XawtextResizeWidth); num_args++; XtSetArg(args[num_args], XtNstring, ""); num_args++; r_text = XtCreateManagedWidget("replaceText", asciiTextWidgetClass, form, args, num_args); search->rep_text = r_text; num_args = 0; XtSetArg(args[num_args], XtNlabel, "Search"); num_args++; XtSetArg(args[num_args], XtNfromVert, r_text); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; search_button = XtCreateManagedWidget("search", commandWidgetClass, form, args, num_args); num_args = 0; XtSetArg(args[num_args2F} XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SP|R/], XtNlabel, "Replace"); num_args++; XtSetArg(args[num_args], XtNfromVert, r_text); num_args++; XtSetArg(args[num_args], XtNfromHoriz, search_button); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; search->rep_one = XtCreateManagedWidget("replaceOne", commandWidgetClass, form, args, num_args); num_args = 0; XtSetArg(args[num_args], XtNlabel, "Replace All"); num_args++; XtSetArg(args[num_args], XtNfromVert, r_text); num_args++; XtSetArg(args[num_args], XtNfromHoriz, search->rep_one); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; search->rep_all = XtCreateManagedWidget("replaceAll", commandWidgetClass, form, args, num_args); num_args = 0; XtSetArg(args[num_args], XtNlabel, "Cancel"); num_args++; XtSetArg(args[num_args], XtNfromVert, r_text); num_args++; XtSetArg(args[num_args], XtNfromHoriz, search->rep_all); num_args++; XtSetArg(args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(args[num_args], XtNright, XtChainLeft); num_args++; cancel = XtCreateManagedWidget("cancel", commandWidgetClass, form, args, num_args); XtAddCallback(search_button, XtNcallback, SearchButton, (caddr_t) search); XtAddCallback(search->rep_one, XtNcallback, DoReplaceOne, (caddr_t) search); XtAddCallback(search->rep_all, XtNcallback, DoReplaceAll, (caddr_t) search); XtAddCallback(cancel, XtNcallbU XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SP^2ack, PopdownSearch, (caddr_t) search); /* * Initialize the text entry fields. */ { Pixel color; num_args = 0; XtSetArg(args[num_args], XtNbackground, &color); num_args++; XtGetValues(search->rep_text, args, num_args); num_args = 0; XtSetArg(args[num_args], XtNborderColor, color); num_args++; XtSetValues(search->rep_text, args, num_args); XtSetKeyboardFocus(form, search->search_text); } SetSearchLabels(search, SEARCH_LABEL_1, SEARCH_LABEL_2, FALSE); /* * Bind Extra translations. */ trans = XtParseTranslationTable(search_text_trans); XtOverrideTranslations(search->search_text, trans); trans = XtParseTranslationTable(rep_text_trans); XtOverrideTranslations(search->rep_text, trans); } /* Function Name: DoSearch * Description: Performs a search. * Arguments: search - the serach structure. * Returns: TRUE if sucessful. */ /* ARGSUSED */ static Boolean DoSearch(search) struct SearchAndReplace * search; { char msg[BUFSIZ]; Widget tw = XtParent(search->search_popup); XawTextPosition pos; XawTextScanDirection dir; XawTextBlock text; text.ptr = GetString(search->search_text); text.length = strlen(text.ptr); text.firstPos = 0; text.format = FMT8BIT; dir = (XawTextScanDirection) (XawToggleGetCurrent(search->left_toggle) - R_OFFSET); pos = XawTextSearch( tw, dir, &text); if (pos == XawTextSearchError) sprintf( msg, "Could not find string '%s'.", text.ptr); else { if (dir == XawsdRight) XawTextSetInsertionPoint_ XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SP75( tw, pos + text.length); else XawTextSetInsertionPoint( tw, pos); XawTextSetSelection( tw, pos, pos + text.length); search->selection_changed = FALSE; /* selection is good. */ return(TRUE); } XawTextUnsetSelection(tw); SetSearchLabels(search, msg, "", TRUE); return(FALSE); } /************************************************************ * * This section of the file contains all the functions that * the replace dialog box uses. * ************************************************************/ /* Function Name: _XawTextDoReplaceAction * Description: Action routine that can be bound to dialog box's * Text Widget that will replace a string in the main * Text Widget. * Arguments: (Standard Action Routine args) * Returns: none. */ /* ARGSUSED */ void _XawTextDoReplaceAction(w, event, params, num_params) Widget w; XEvent *event; String * params; Cardinal * num_params; { TextWidget ctx = (TextWidget) XtParent(XtParent(XtParent(w))); Boolean popdown = FALSE; if ( (*num_params == 1) && ((params[0][0] == 'p') || (params[0][0] == 'P')) ) popdown = TRUE; if (Replace( ctx->text.search, TRUE, popdown) && popdown) PopdownSearch(w, (caddr_t) ctx->text.search, NULL); } /* Function Name: DoReplaceOne * Description: Replaces the first instance of the string * in the search dialog's text widget * with the one in the replace dialog's text widget. * Arguments: w - *** oq# XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SP-8Not Used ***. * closure - a pointer to the search structure. * call_data - *** Not Used ***. * Returns: none. */ /* ARGSUSED */ static void DoReplaceOne(w, closure, call_data) Widget w; /* The Button Pressed. */ caddr_t closure; /* Text Widget. */ caddr_t call_data; /* unused */ { Replace( (struct SearchAndReplace *) closure, TRUE, FALSE); } /* Function Name: DoReplaceOne * Description: Replaces every instance of the string * in the search dialog's text widget * with the one in the replace dialog's text widget. * Arguments: w - *** Not Used ***. * closure - a pointer to the search structure. * call_data - *** Not Used ***. * Returns: none. */ /* ARGSUSED */ static void DoReplaceAll(w, closure, call_data) Widget w; /* The Button Pressed. */ caddr_t closure; /* Text Widget. */ caddr_t call_data; /* unused */ { Replace( (struct SearchAndReplace *) closure, FALSE, FALSE); } /* Function Name: Replace * Description: This is the function that does the real work of * replacing strings in the main text widget. * Arguments: tw - the Text Widget to replce the string in. * once_only - If TRUE then only replace the first one found. * other replace all of them. * show_current - If true then leave the selection on the * string that was just replaced, otherwise * D XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4C;2SP; move it onto the next one. * Returns: none. */ static Boolean Replace(search, once_only, show_current) struct SearchAndReplace * search; Boolean once_only, show_current; { XawTextPosition pos, new_pos, end_pos; XawTextScanDirection dir; XawTextBlock find, replace; Widget tw = XtParent(search->search_popup); int count = 0; find.ptr = GetString( search->search_text); find.length = strlen(find.ptr); find.firstPos = 0; find.format = FMT8BIT; replace.ptr = GetString(search->rep_text); replace.length = strlen(replace.ptr); replace.firstPos = 0; replace.format = FMT8BIT; dir = (XawTextScanDirection) (XawToggleGetCurrent(search->left_toggle) - R_OFFSET); while (TRUE) { if (count != 0) { new_pos = XawTextSearch( tw, dir, &find); if ( (new_pos == XawTextSearchError) ) { if (count == 0) { char msg[BUFSIZ]; sprintf( msg, "%s %s %s", "*** Error: Could not find string '", find.ptr, "'. ***"); SetSearchLabels(search, msg, "", TRUE); return(FALSE); } else break; } pos = new_pos; end_pos = pos + find.length; } else { XawTextGetSelectionPos(tw, &pos, &end_pos); if (search->selection_changed) { SetSearchLabels(search, "Selection has been modified, aborting.", "", TRUE); return(FALSE); } if (pos == end_pos) return(FALSE); } if (XawTextReplace(tw, pos, end_pos, &replace) != XawEditDone) { char msg[BUFSIZ]; sprintf( msg, "'%s' with '%s'. ***}; XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4H;2SP>", find.ptr, replace.ptr); SetSearchLabels(search, "*** Error while replacing", msg, TRUE); return(FALSE); } if (once_only) if (show_current) break; else { DoSearch(search); return(TRUE); } count++; } if (dir == XawsdRight) XawTextSetInsertionPoint( tw, pos + replace.length); else XawTextSetInsertionPoint( tw, pos); if (replace.length == 0) XawTextUnsetSelection(tw); else XawTextSetSelection( tw, pos, pos + replace.length); return(TRUE); } /* Function Name: SetSearchLabels * Description: Sets both the search labels, and also rings the bell * Arguments: search - the search structure. * msg1, msg2 - message to put in each search label. * bell - if TRUE then ring bell. * Returns: none. */ static void SetSearchLabels(search, msg1, msg2, bell) struct SearchAndReplace * search; String msg1, msg2; Boolean bell; { (void) SetResource( search->label1, XtNlabel, (XtArgVal) msg1); (void) SetResource( search->label2, XtNlabel, (XtArgVal) msg2); if (bell) XBell(XtDisplay(search->search_popup), 0); } /************************************************************ * * This section of the file contains utility routines used by * other functions in this file. * ************************************************************/ /* Function Name: _XawTextSetField * Description: Action routine that can be bound to dialog box's * Text Widget that will send input to the field spG Z5JbN]aYAO|~pMQt m(.IC:5w \=7d@$k/#L=k+A&FB&f0L@c0J4hVV,]W].K'=S6Qe O$J+X$EeL=FPVS U8c C&RH5k|w8%LLy)W0/[m\}|]R[5nqdY| }>2 _ ITo/ }Np`RQVIsZzXogCNsRhXob)#?U6V?F @f-_=gjq4C|hO<7,jE].%6hYC8VBGB-B=FxI!T8 C`rwFp;uQ(<9p(4bek;:4 *P'ZrOK;{NY>Y\y Ti%50> ^ymD qAk/osL2V3tYCUE?0/0@r81MbR1c0r:LSD?j-Ha9:N .9OU:SrIAQgQya\bz@g}iZ^M!r8R|_HJ2b2Qi= pV"RSK(VT~CmdF5'~ua'-S eJL~0 @ hLO?f,Pj gf'Y (:M.D1 Mo\.ag6" a_yK)YCD2U>CIUP~7Re~RGp)/ @E'ck {j[)aie,YSVO,,/i&?+wbAvQ[ &eJ?41ZSd`V Mz8 \tg!*c_WUMm!p`u)NN-V<VEXA=IL ym 2~B T7}f,i<8QQ~C/#AW.aYrP*\,-^Zt?y=;(% y?PyS0`!`Ys79?Z R! w@i?|c+|]g%,v9!#oAn-Yx$ RXIQ:GFdy +%X{/|y;x`vE3}, wh`(E;%:R`rp9  %XD)N:TW n6i2x1dCxyMs^3^s_ F4 !K/oDRpyWb`! ^w )H/U2Z*UY`[B2WY.e]\#faJ?!duDEZ*x#yuii^j\Uv+i+]3=Sf;D1 :l]@$Tl' Hnpdp0<VdNLY61n[y2}1unl K[N?7Gl23(OZ2 \|2]$sT8C;C2Z01,G/-'MFV_rXn@, >OW(G2aI*k}Jg\:T:p6q0({1S?#^Fafw*{@2d%loDb HXQG h|e( 'w +'aAXenW5\CG!1L,z9|H]$uS ZIAD#S25y\RjWaI|1wCdF\k~NBM+XV1#& ;#r=T$ CIz9OL8*K)j H|O$~XVul-Z"A LP]))*x]RedGb&jA61n   &F=^.9U~]E12RTZ]*,0;K"I<% XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4H;2;1SP?Aecified. * Arguments: (Standard Action Routine args) * Returns: none. */ /* ARGSUSED */ void _XawTextSetField(w, event, params, num_params) Widget w; XEvent *event; String * params; Cardinal * num_params; { struct SearchAndReplace * search; Widget new, old; search = ((TextWidget) XtParent(XtParent(XtParent(w))))->text.search; if (*num_params != 1) { SetSearchLabels(search, "*** Error: SetField Action must have", "exactly one argument. ***", TRUE); return; } switch (params[0][0]) { case 's': case 'S': new = search->search_text; old = search->rep_text; break; case 'r': case 'R': old = search->search_text; new = search->rep_text; break; default: SetSearchLabels(search, "*** Error: SetField Action's first Argument must", "be either 'Search' or 'Replace'. ***", TRUE); return; } _SetField(new, old); } /* Function Name: SetField * Description: Sets the current text field. * Arguments: new, old - new and old text fields. * Returns: none */ static void _SetField(new, old) Widget new, old; { Arg args[2]; Pixel new_border, old_border, old_bg; if (!XtIsSensitive(new)) { XBell(XtDisplay(old), 0); /* Don't set field to an inactive Widget. */ return; } XtSetKeyboardFocus(XtParent(new), new); XtSetArg(args[0], XtNborderColor, &old_border); XtSetArg(args[1], XtNbackground, &old_bg); XtGetValues(new, args, TWO); XtSetArg(args[0], XtNborderColor, &new_border); XtGetValues(old, args, ONE); if kA XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4H;2;1SPD(old_border != old_bg) /* Colors are already correct, return. */ return; SetResource(old, XtNborderColor, (XtArgVal) old_border); SetResource(new, XtNborderColor, (XtArgVal) new_border); } /* Function Name: SetResourceByName * Description: Sets a resource in any of the dialog children given * name of the child and the shell widget of the dialog. * Arguments: shell - shell widget of the popup. * name - name of the child. * res_name - name of the resource. * value - the value of the resource. * Returns: TRUE if sucessful. */ static Boolean SetResourceByName(shell, name, res_name, value) Widget shell; char * name, * res_name; XtArgVal value; { Widget temp_widget; char buf[BUFSIZ]; sprintf(buf, "%s.%s", FORM_NAME, name); if ( (temp_widget = XtNameToWidget(shell, buf)) != NULL) { SetResource(temp_widget, res_name, value); return(TRUE); } return(FALSE); } /* Function Name: SetResource * Description: Sets a resource in a widget * Arguments: w - the widget. * res_name - name of the resource. * value - the value of the resource. * Returns: none. */ static void SetResource(w, res_name, value) Widget w; char * res_name; XtArgVal value; { Arg args[1]; XtSetArg(args[0], res_name, value); XtSetValues( w, args, ONE ); } /* Function Name: GetString * Description: Gets the value for the string in the popup. * Arguments: text - the text widget whose string we will >(0 XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;40SPTGget. * Returns: the string. */ static String GetString(text) Widget text; { String string; Arg args[1]; XtSetArg( args[0], XtNstring, &string ); XtGetValues( text, args, ONE ); return(string); } /* Function Name: CenterWidgetOnPoint. * Description: Centers a shell widget on a point relative to * the root window. * Arguments: w - the shell widget. * event - event containing the location of the point * Returns: none. * * NOTE: The widget is not allowed to go off the screen. */ static void CenterWidgetOnPoint(w, event) Widget w; XEvent *event; { Arg args[3]; Cardinal num_args; Dimension width, height, b_width; Position x, y, max_x, max_y; if (event != NULL) { switch (event->type) { case ButtonPress: case ButtonRelease: x = event->xbutton.x_root; y = event->xbutton.y_root; break; case KeyPress: case KeyRelease: x = event->xkey.x_root; y = event->xkey.y_root; break; default: return; } } num_args = 0; XtSetArg(args[num_args], XtNwidth, &width); num_args++; XtSetArg(args[num_args], XtNheight, &height); num_args++; XtSetArg(args[num_args], XtNborderWidth, &b_width); num_args++; XtGetValues(w, args, num_args); width += 2 * b_width; height += 2 * b_width; x -= ( (Position) width/2 ); if (x < 0) x = 0; if ( x > (max_x = (Position) (XtScreen(w)->width - width)) ) x = max_x; y -= ( (Position) height/2 ); if (y < 0) y = 0; if ( y > (max_y = (Posit#Kl XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTPOP.C;4R;1SPʢJion) (XtScreen(w)->height - height)) ) y = max_y; num_args = 0; XtSetArg(args[num_args], XtNx, x); num_args++; XtSetArg(args[num_args], XtNy, y); num_args++; XtSetValues(w, args, num_args); } /* Function Name: CreateDialog * Description: Actually creates a dialog. * Arguments: parent - the parent of the dialog - the main text widget. * ptr - initial_string for the dialog. * name - name of the dialog. * func - function to create the children of the dialog. * Returns: the popup shell of the dialog. * * NOTE: * * The function argument is passed the following arguements. * * form - the from widget that is the dialog. * ptr - the initial string for the dialog's text widget. * parent - the parent of the dialog - the main text widget. */ static Widget CreateDialog(parent, ptr, name, func) Widget parent; String ptr, name; void (*func)(); { Widget popup, form; Arg args[4]; Cardinal num_args; num_args = 0; XtSetArg(args[num_args], XtNiconName, name); num_args++; XtSetArg(args[num_args], XtNgeometry, NULL); num_args++; XtSetArg(args[num_args], XtNallowShellResize, TRUE); num_args++; XtSetArg(args[num_args], XtNsaveUnder, TRUE); num_args++; popup = XtCreatePopupShell(name, transientShellWidgetClass, parent, args, XtNumber(args) ); form = XtCreateManagedWidget(FORM_NAME, formWidgetClass, popup, NULL, ZERO); (*func) (form, ptr, parent); return(popup); }  XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;2;1V-ל!*[MAHAN.XTERM.LIB.XAW]TEXTSINK.C;2+,r.-/@ 4V-,s(F-zr0123KPWO-56s(F7+H(F8Po9G@HJ#if ( !defined(lint) && !defined(SABER) ) static char Xrcsid[] = "$XConsortium: TextSink.c,v 1.9 89/11/21 15:53:22 swick 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, IND XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;2;1V-JIRECT 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 AsciiSink. */ /* * TextSink.c - TextSink object. (For use with the text widget). * */ #define XAW_TEXT_SINK_OBJECT #include #include #ifdef vax11c #include #include #include "XawInit.h" #include "TextSinkP.h" #include "TextP.h" #else #include #include #include #include #include #endif /* vax11c */ /**************************************************************** * * Full class record constant * ****************************************************************/ static void ClassPartInitialize(), Initialize(), Destroy(); static Boolean SetValues(); static int MaxHeight(), MaxLines(); static void DisplayText(), InsertCursor(), ClearToBackground(), FindPosition(); static void FindDistance(), Resolve(), SetTabs(), GetCursorBounds(); #define offset(field) XtOffset(TextSinkObject, text_sink.field) static XtResource resources[] = { {XtNfont, XtCFont, XtRFontStruct, sizeof (XFontStruct *), offset(font), XtRString, XtDefaultFont}, {XtNforeground, XtCForeground, XtRPixel, sizeof (Pixel), c{ XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;2V-koffset(foreground), XtRString, XtDefaultForeground}, {XtNbackground, XtCBackground, XtRPixel, sizeof (Pixel), offset(background), XtRString, XtDefaultBackground}, }; #undef offset #define SuperClass (&objectClassRec) #ifdef vax11c globaldef {"textsinkclassrec"} noshare #endif /* vax11c */ TextSinkClassRec textSinkClassRec = { { /* core_class fields */ /* superclass */ (WidgetClass) SuperClass, /* class_name */ "TextSink", /* widget_size */ sizeof(TextSinkRec), /* class_initialize */ XawInitializeWidgetSet, /* class_part_initialize */ ClassPartInitialize, /* 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 }, /* textSink_class fields */ { /* DisplayText */ DisplayText, /* InsertCursor */ I^_p XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;2V-! nsertCursor, /* ClearToBackground */ ClearToBackground, /* FindPosition */ FindPosition, /* FindDistance */ FindDistance, /* Resolve */ Resolve, /* MaxLines */ MaxLines, /* MaxHeight */ MaxHeight, /* SetTabs */ SetTabs, /* GetCursorBounds */ GetCursorBounds, } }; #ifdef vax11c globaldef {"textsinkobjectclass"} noshare #endif /* vax11c */ WidgetClass textSinkObjectClass = (WidgetClass)&textSinkClassRec; static void ClassPartInitialize(wc) WidgetClass wc; { register TextSinkObjectClass t_src, superC; t_src = (TextSinkObjectClass) wc; superC = (TextSinkObjectClass) t_src->object_class.superclass; /* * We don't need to check for null super since we'll get to TextSink * eventually. */ if (t_src->text_sink_class.DisplayText == XtInheritDisplayText) t_src->text_sink_class.DisplayText = superC->text_sink_class.DisplayText; if (t_src->text_sink_class.InsertCursor == XtInheritInsertCursor) t_src->text_sink_class.InsertCursor = superC->text_sink_class.InsertCursor; if (t_src->text_sink_class.ClearToBackground== XtInheritClearToBackground) t_src->text_sink_class.ClearToBackground = superC->text_sink_class.ClearToBackground; if (t_src->text_sink_class.FindPosition == XtInheritFindPosition) t_src->text_sink_class.FindPosi+- XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;2V-R tion = superC->text_sink_class.FindPosition; if (t_src->text_sink_class.FindDistance == XtInheritFindDistance) t_src->text_sink_class.FindDistance = superC->text_sink_class.FindDistance; if (t_src->text_sink_class.Resolve == XtInheritResolve) t_src->text_sink_class.Resolve = superC->text_sink_class.Resolve; if (t_src->text_sink_class.MaxLines == XtInheritMaxLines) t_src->text_sink_class.MaxLines = superC->text_sink_class.MaxLines; if (t_src->text_sink_class.MaxHeight == XtInheritMaxHeight) t_src->text_sink_class.MaxHeight = superC->text_sink_class.MaxHeight; if (t_src->text_sink_class.SetTabs == XtInheritSetTabs) t_src->text_sink_class.SetTabs = superC->text_sink_class.SetTabs; if (t_src->text_sink_class.GetCursorBounds == XtInheritGetCursorBounds) t_src->text_sink_class.GetCursorBounds = superC->text_sink_class.GetCursorBounds; } /* 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; { TextSinkObject sink = (TextSinkObject) new; sink->text_sink.tab_count = 0; /* Initialize the tab stops. */ sink->text_sink.tabs = NULL; sink->text_sink.char_tabs = NULL; } /* Function Name: Destroy * De^ XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;2V-Rscription: This function cleans up when the object is * destroyed. * Arguments: w - the TextSink Object. * Returns: none. */ static void Destroy(w) { TextSinkObject sink = (TextSinkObject) w; if (sink->text_sink.tabs != NULL) XtFree((char *) sink->text_sink.tabs); } /* Function Name: SetValues * Description: Sets the values for the TextSink * Arguments: current - 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; { TextSinkObject w = (TextSinkObject) new; TextSinkObject old_w = (TextSinkObject) current; TextSinkObjectClass class = (TextSinkObjectClass) w->object.widget_class; if (w->text_sink.font != old_w->text_sink.font) { (*class->text_sink_class.SetTabs)(new, w->text_sink.tab_count, w->text_sink.char_tabs); ((TextWidget)XtParent(new))->text.redisplay_needed = True; } else { if (w->text_sink.foreground != old_w->text_sink.foreground) ((TextWidget)XtParent(new))->text.redisplay_needed = True; } return FALSE; } /************************************************************ * * Class specific methods. * ************************************************************/ /* Function Name: DisplayText * Description: Stub function that in subclasses will display text. * Arguments: w - the TextSink Object. * Ѳb;1H Je@#QyOuOG:T \s2K2Vz8Jk[y'e']QJr2d:A5jcOjJUB.#\k-uK-PcdU43I\IFD|eNd|dio|^n_[e U9~ 3(z>qL4HS{*6h5~4BvM/=lp)\O {g"N 6v6eVF<"d$=b&Ml Tyh_WVQZ;qd->u5#TrK3S(CLRF>.RJ[wPV MS @DB`.Rh*)4,=gp}rJq@.n)l]`(O(K`jbQSA=bJX8REd{/`RU9nqSE , 07G7">uTa-/S0D@s%UO r;(jq6i$]x&ES7 dTZPCeTdR\DjOC.WiHr 7P`k{C@^5%F[> .bp'3{6Y C+$??:MaqP@pOHZua9Ajqtj0 VYXnokT?Dk0f8Lw{8xPEv!8L45UHHGgz*uY.80}o)4"SdITPyvVR.gbB%%AHjFB2?zt*.hv,PK7Eep9Z|upcS( !w(]wXfH@us[<E8=NM &}q AS g]andYb&:c:tM^E_(9C/>SW XzrY Pa+;QUn{X^V[L63ErI?rT"1SQz$Xq'A tP&ah6{E]{[o~2, w9k6q,)\F V::X` I0@gCRR Zh^'G}72RXf{} &/prQ+K: @ YhtiT ND_~U Mj>/ zk!e@@JIkk 2Yd&1-^ T9vF{IS!n[L:CNGwG< h:/ &eL5,#8YlB>Yvwh*2!dF!>"/]$V12Qybd,NAR3L9Pa3 9~slc|0t1U XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;2V- x, y - location to start drawing text. * pos1, pos2 - location of starting and ending points * in the text buffer. * highlight - hightlight this text? * Returns: none. * * This function doesn't actually display anything, it is only a place * holder. */ /* ARGSUSED */ static void DisplayText(w, x, y, pos1, pos2, highlight) Widget w; Position x, y; Boolean highlight; XawTextPosition pos1, pos2; { return; } /* Function Name: InsertCursor * Description: Places the InsertCursor. * Arguments: w - the TextSink Object. * x, y - location for the cursor. * staye - whether to turn the cursor on, or off. * Returns: none. * * This function doesn't actually display anything, it is only a place * holder. */ /* ARGSUSED */ static void InsertCursor(w, x, y, state) Widget w; Position x, y; XawTextInsertState state; { return; } /* Function Name: ClearToBackground * Description: Clears a region of the sink to the background color. * Arguments: w - the TextSink Object. * x, y - location of area to clear. * width, height - size of area to clear * Returns: void. * */ /* ARGSUSED */ static void ClearToBackground (w, x, y, width, height) Widget w; Position x, y; Dimension width, height; { /* * Don't clear in height or width are zero. * XClearArea() has special semantic for these values. */ if ( (height == 0) || (width == 0) ) return; XClearArea(XtDisplayOfObjeb XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;2V- -ct(w), XtWindowOfObject(w), x, y, width, height, False); } /* Function Name: FindPosition * Description: Finds a position in the text. * Arguments: w - the TextSink Object. * fromPos - reference position. * fromX - reference location. * width, - width of section to paint text. * stopAtWordBreak - returned position is a word break? * resPos - Position to return. *** RETURNED *** * resWidth - Width actually used. *** RETURNED *** * resHeight - Height actually used. *** RETURNED *** * Returns: none (see above). */ /* ARGSUSED */ static void FindPosition(w, fromPos, fromx, width, stopAtWordBreak, resPos, resWidth, resHeight) Widget w; XawTextPosition fromPos; int fromx, width; Boolean stopAtWordBreak; XawTextPosition *resPos; int *resWidth, *resHeight; { *resPos = fromPos; *resHeight = *resWidth = 0; } /* Function Name: FindDistance * Description: Find the Pixel Distance between two text Positions. * Arguments: w - the TextSink Object. * fromPos - starting Position. * fromX - x location of starting Position. * toPos - end Position. * resWidth - Distance between fromPos and toPos. * resPos - Acutal toPos used. * resHeight - Height required by this text. * Returns: none. */ /* ARGSUSED */ static void FindDistance (w, fromPos, fromx, toPos, resWiN XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;2V-dth, resPos, resHeight) Widget w; XawTextPosition fromPos; int fromx; XawTextPosition toPos; int *resWidth; XawTextPosition *resPos; int *resHeight; { *resWidth = *resHeight = 0; *resPos = fromPos; } /* Function Name: Resolve * Description: Resloves a location to a position. * Arguments: w - the TextSink Object. * pos - a reference Position. * fromx - a reference Location. * width - width to move. * resPos - the resulting position. * Returns: none */ /* ARGSUSED */ static void Resolve (w, pos, fromx, width, resPos) Widget w; XawTextPosition pos; int fromx, width; XawTextPosition *resPos; { *resPos = pos; } /* Function Name: MaxLines * Description: Finds the Maximum number of lines that will fit in * a given height. * Arguments: w - the TextSink Object. * height - height to fit lines into. * Returns: the number of lines that will fit. */ /* ARGSUSED */ static int MaxLines(w, height) Widget w; Dimension height; { TextSinkObject sink = (TextSinkObject) w; int font_height; font_height = sink->text_sink.font->ascent + sink->text_sink.font->descent; return( ((int) height) / font_height ); } /* Function Name: MaxHeight * Description: Finds the Minium height that will contain a given number * lines. * Arguments: w - the TextSink Object. * lines - the number of lines. * Returns: the height. */ /* ARGSUSED */ static int MaxHeight(w, lines) Widget w; o XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;22V-O/int lines; { TextSinkObject sink = (TextSinkObject) w; return(lines * (sink->text_sink.font->ascent + sink->text_sink.font->descent)); } /* Function Name: SetTabs * Description: Sets the Tab stops. * Arguments: w - the TextSink Object. * tab_count - the number of tabs in the list. * tabs - the text positions of the tabs. * Returns: none */ static void SetTabs(w, tab_count, tabs) Widget w; int tab_count; short *tabs; { TextSinkObject sink = (TextSinkObject) w; int i; Atom XA_FIGURE_WIDTH; unsigned long figure_width = 0; XFontStruct *font = sink->text_sink.font; /* * Find the figure width of the current font. */ XA_FIGURE_WIDTH = XInternAtom(XtDisplayOfObject(w), "FIGURE_WIDTH", FALSE); if ( (XA_FIGURE_WIDTH != NULL) && ( (!XGetFontProperty(font, XA_FIGURE_WIDTH, &figure_width)) || (figure_width == 0)) ) if (font->per_char && font->min_char_or_byte2 <= '$' && font->max_char_or_byte2 >= '$') figure_width = font->per_char['$' - font->min_char_or_byte2].width; else figure_width = font->max_bounds.width; if (tab_count > sink->text_sink.tab_count) { sink->text_sink.tabs = (Position *) XtRealloc(sink->text_sink.tabs, (Cardinal) (tab_count * sizeof(Position))); sink->text_sink.char_tabs = (short *) XtRealloc(sink->text_sink.char_tabs, (Cardinal) (tab_count * sizeof(short))); } for ( i = 0 ; i < tab_count ; i++ ) { sink->text_sink.tabs[i] = tabs[i] * figure_width; sink->text  XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;22V-Ҷ_sink.char_tabs[i] = tabs[i]; } sink->text_sink.tab_count = tab_count; } /* Function Name: GetCursorBounds * Description: Finds the bounding box for the insert curor (caret). * Arguments: w - the TextSinkObject. * rect - an X rectance containing the cursor bounds. * Returns: none (fills in rect). */ /* ARGSUSED */ static void GetCursorBounds(w, rect) Widget w; XRectangle * rect; { rect->x = rect->y = rect->width = rect->height = 0; } /************************************************************ * * Public Functions. * ************************************************************/ /* Function Name: XawTextSinkDisplayText * Description: Stub function that in subclasses will display text. * Arguments: w - the TextSink Object. * x, y - location to start drawing text. * pos1, pos2 - location of starting and ending points * in the text buffer. * highlight - hightlight this text? * Returns: none. * * This function doesn't actually display anything, it is only a place * holder. */ /* ARGSUSED */ void XawTextSinkDisplayText(w, x, y, pos1, pos2, highlight) Widget w; Position x, y; Boolean highlight; XawTextPosition pos1, pos2; { TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class; (*class->text_sink_class.DisplayText)(w, x, y, pos1, pos2, highlight); } /* Function Name: XawTextSinkInsertCursor * Description: Places the InsertCursor. * Arguments: w - the TextSink Objec"P XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;22V-v\!t. * x, y - location for the cursor. * staye - whether to turn the cursor on, or off. * Returns: none. * * This function doesn't actually display anything, it is only a place * holder. */ /* ARGSUSED */ void XawTextSinkInsertCursor(w, x, y, state) Widget w; Position x, y; XawTextInsertState state; { TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class; (*class->text_sink_class.InsertCursor)(w, x, y, state); } /* Function Name: XawTextSinkClearToBackground * Description: Clears a region of the sink to the background color. * Arguments: w - the TextSink Object. * x, y - location of area to clear. * width, height - size of area to clear * Returns: void. * * This function doesn't actually display anything, it is only a place * holder. */ /* ARGSUSED */ void XawTextSinkClearToBackground (w, x, y, width, height) Widget w; Position x, y; Dimension width, height; { TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class; (*class->text_sink_class.ClearToBackground)(w, x, y, width, height); } /* Function Name: XawTextSinkFindPosition * Description: Finds a position in the text. * Arguments: w - the TextSink Object. * fromPos - reference position. * fromX - reference location. * width, - width of section to paint text. * stopAtWordBreak - returned position is a word break? * resPos - Position to return.MK XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;22V-$ *** RETURNED *** * resWidth - Width actually used. *** RETURNED *** * resHeight - Height actually used. *** RETURNED *** * Returns: none (see above). */ /* ARGSUSED */ void XawTextSinkFindPosition(w, fromPos, fromx, width, stopAtWordBreak, resPos, resWidth, resHeight) Widget w; XawTextPosition fromPos; int fromx, width; Boolean stopAtWordBreak; XawTextPosition *resPos; int *resWidth, *resHeight; { TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class; (*class->text_sink_class.FindPosition)(w, fromPos, fromx, width, stopAtWordBreak, resPos, resWidth, resHeight); } /* Function Name: XawTextSinkFindDistance * Description: Find the Pixel Distance between two text Positions. * Arguments: w - the TextSink Object. * fromPos - starting Position. * fromX - x location of starting Position. * toPos - end Position. * resWidth - Distance between fromPos and toPos. * resPos - Acutal toPos used. * resHeight - Height required by this text. * Returns: none. */ /* ARGSUSED */ void XawTextSinkFindDistance (w, fromPos, fromx, toPos, resWidth, resPos, resHeight) Widget w; XawTextPosition fromPos, toPos, *resPos; int fromx, *resWidth, *resHeight; { TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class; (*class->text_sink_class.FindDistance)(w, fromPos, fromx, toPos, resWidth, resPos, resHeight); } /* w XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;22V-='Function Name: XawTextSinkResolve * Description: Resloves a location to a position. * Arguments: w - the TextSink Object. * pos - a reference Position. * fromx - a reference Location. * width - width to move. * resPos - the resulting position. * Returns: none */ /* ARGSUSED */ void XawTextSinkResolve(w, pos, fromx, width, resPos) Widget w; XawTextPosition pos; int fromx, width; XawTextPosition *resPos; { TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class; (*class->text_sink_class.Resolve)(w, pos, fromx, width, resPos); } /* Function Name: XawTextSinkMaxLines * Description: Finds the Maximum number of lines that will fit in * a given height. * Arguments: w - the TextSink Object. * height - height to fit lines into. * Returns: the number of lines that will fit. */ /* ARGSUSED */ int XawTextSinkMaxLines(w, height) Widget w; Dimension height; { TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class; return((*class->text_sink_class.MaxLines)(w, height)); } /* Function Name: XawTextSinkMaxHeight * Description: Finds the Minium height that will contain a given number * lines. * Arguments: w - the TextSink Object. * lines - the number of lines. * Returns: the height. */ /* ARGSUSED */ int XawTextSinkMaxHeight(w, lines) Widget w; int lines; { TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class; rt$  XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.C;22V-P*eturn((*class->text_sink_class.MaxHeight)(w, lines)); } /* Function Name: XawTextSinkSetTabs * Description: Sets the Tab stops. * Arguments: w - the TextSink Object. * tab_count - the number of tabs in the list. * tabs - the text positions of the tabs. * Returns: none */ void XawTextSinkSetTabs(w, tab_count, tabs) Widget w; int tab_count, *tabs; { if (tab_count > 0) { TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class; short *char_tabs = (short*)XtMalloc( (unsigned)tab_count*sizeof(short) ); register short *tab; register int i; for (i = tab_count, tab = char_tabs; i; i--) *tab++ = (short)*tabs++; (*class->text_sink_class.SetTabs)(w, tab_count, char_tabs); XtFree((XtPointer)char_tabs); } } /* Function Name: XawTextSinkGetCursorBounds * Description: Finds the bounding box for the insert curor (caret). * Arguments: w - the TextSinkObject. * rect - an X rectance containing the cursor bounds. * Returns: none (fills in rect). */ /* ARGSUSED */ void XawTextSinkGetCursorBounds(w, rect) Widget w; XRectangle * rect; { TextSinkObjectClass class = (TextSinkObjectClass) w->core.widget_class; (*class->text_sink_class.GetCursorBounds)(w, rect); } 3 XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.H;22N#!*[MAHAN.XTERM.LIB.XAW]TEXTSINK.H;2+,r./@ 4NЛ1F-zr0123KPWO56Л1F7]F8P9o9G@HJ/* * $XConsortium: TextSink.h,v 1.5 89/11/01 17:28:26 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"{ 2",Xg3m$x~];XNE[rH%vc6-$WTz~`Qs.lcB9f8\B8r 4VFlA5zf8_Gwk% YH5FrX3/]nQK<|?B}E ,AIG*- -Aa"H2Y$A+@xXfX>^o}V,e+8B&vUk\mOqJ|JmfKcZ~?s_U\&z*6Oa3CK\.L9_GdO9E)LPV%Wv ;U 8Ll0q?LT&&-Uppf.}.?Gl6 R f@=![/a,Av%(&QFa04lV=4``* )Vk>:h &( >1`dLFb8h I{K$d/6vGfbRL,K  Ow^ ( _"aHLyusa1w4!s9"7 3;T3@%_XR(P5" >)^*=GA8qai O~)@u<2 =6XlkF 1Z/:})wsyJ0V2WwM+wfLd0+lXbfg`(G{QgIY""=pwI0 xmh:h$*r"2z9 p%zf3j'l Reit n[Z  .b5FcvC+]>cwy*%tRPYq7USx 'HZ&xT;L;UkYaMGyECpJH>g^EDrEV$1*a2Ix+qjSS2>96p3[O+M]3w$-e!Cw($cl I #else #include #endif /* vax11c */ /* Resources: Name Class RepType Default Value ---- ----- ------- ------------- font Font XFontStruct * XtDefaultFont foreground Foreground Pixel XtDefaultForeground background Background Pixel XtDefaultBackground */ /* Class record constants */ #ifndef XAW_TEXT_SINK_OBJECT #ifdef vax11c globalref WidgetClass textSinkObjectClass; #else extern WidgetClass textSinkObjectClass; #endif /* vax11c */ #endif /* !XAW_TEXT_SINK_OBJECT */ typedef struct _TextSinkClassRec *TextSinkObjectClass; typedef struct _TextSinkRec *TextSinkObject; typedef enum {XawisOn, XawisOff} XawTextInsertState; /************************************************************ * * Public Functions. * ************************************************************/ /* Function Name: XawTextSinkDisplayText * Description: Stub function that in subο XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.H;22Nclasses will display text. * Arguments: w - the TextSink Object. * x, y - location to start drawing text. * pos1, pos2 - location of starting and ending points * in the text buffer. * highlight - hightlight this text? * Returns: none. * * This function doesn't actually display anything, it is only a place * holder. */ void XawTextSinkDisplayText(/* w, x, y, pos1, pos2, highlight */); /* Widget w; Position x, y; Boolean highlight; XawTextPosition pos1, pos2; */ /* Function Name: XawTextSinkInsertCursor * Description: Places the InsertCursor. * Arguments: w - the TextSink Object. * x, y - location for the cursor. * staye - whether to turn the cursor on, or off. * Returns: none. * * This function doesn't actually display anything, it is only a place * holder. */ void XawTextSinkInsertCursor( /* w, x, y, state */ ); /* Widget w; Position x, y; XawTextInsertState state; */ /* Function Name: XawTextSinkClearToBackground * Description: Clears a region of the sink to the background color. * Arguments: w - the TextSink Object. * x, y - location of area to clear. * width, height - size of area to clear * Returns: void. * * This function doesn't actually display anything, it is only a place * holder. */ void XawTextSinkClearToBackground (/* w, x, y, width, height */); /* Widget w; Position x, y; Dimension width, height; */ /* Function Name: XawText7z XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.H;22N"I SinkFindPosition * Description: Finds a position in the text. * Arguments: w - the TextSink Object. * fromPos - reference position. * fromX - reference location. * width, - width of section to paint text. * stopAtWordBreak - returned position is a word break? * resPos - Position to return. *** RETURNED *** * resWidth - Width actually used. *** RETURNED *** * resHeight - Height actually used. *** RETURNED *** * Returns: none (see above). */ void XawTextSinkFindPosition(/* w, fromPos, fromx, width, stopAtWordBreak, resPos, resWidth, resHeight */ ); /* Widget w; XawTextPosition fromPos; int fromx, width; Boolean stopAtWordBreak; XawTextPosition *resPos; int *resWidth, *resHeight; */ /* Function Name: XawTextSinkFindDistance * Description: Find the Pixel Distance between two text Positions. * Arguments: w - the TextSink Object. * fromPos - starting Position. * fromX - x location of starting Position. * toPos - end Position. * resWidth - Distance between fromPos and toPos. * resPos - Acutal toPos used. * resHeight - Height required by this text. * Returns: none. */ void XawTextSinkFindDistance (/* w, fromPos, fromx, toPos, resWidth, resPos, resHeight */); /* Widget w; XawTextPosition fromPos, toPos, *resPos; int fromx, *resWidth, *resHeight; */ /* > XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.H;22N Function Name: XawTextSinkResolve * Description: Resloves a location to a position. * Arguments: w - the TextSink Object. * pos - a reference Position. * fromx - a reference Location. * width - width to move. * resPos - the resulting position. * Returns: none */ void XawTextSinkResolve(/* w, pos, fromx, width, resPos */); /* Widget w; XawTextPosition pos; int fromx, width; XawTextPosition *resPos; */ /* Function Name: XawTextSinkMaxLines * Description: Finds the Maximum number of lines that will fit in * a given height. * Arguments: w - the TextSink Object. * height - height to fit lines into. * Returns: the number of lines that will fit. */ int XawTextSinkMaxLines(/* w, height */); /* Widget w; Dimension height; */ /* Function Name: XawTextSinkMaxHeight * Description: Finds the Minium height that will contain a given number * lines. * Arguments: w - the TextSink Object. * lines - the number of lines. * Returns: the height. */ int XawTextSinkMaxHeight(/* w, lines */); /* Widget w; int lines; */ /* Function Name: XawTextSinkSetTabs * Description: Sets the Tab stops. * Arguments: w - the TextSink Object. * tab_count - the number of tabs in the list. * tabs - the text positions of the tabs. * Returns: none */ void XawTextSinkSetTabs(/* w, tab_count, tabs */); /* Widget w; int tab_count, *tabs; */ /* Function Na\ XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSINK.H;22Nime: XawTextSinkGetCursorBounds * Description: Finds the bounding box for the insert curor (caret). * Arguments: w - the TextSinkObject. * rect - an X rectance containing the cursor bounds. * Returns: none (fills in rect). */ void XawTextSinkGetCursorBounds(/* w, rect */); /* Widget w; XRectangle * rect; */ #endif /* _XawTextSrc_h -- DON'T ADD STUFF AFTER THIS #endif */ "*[MAHAN.XTERM.LIB.XAW]TEXTSINKP.H;2+,r . /@ 4N 0F-zr0123KPWO 560F7F80 2p9G@HJ/* * $XConsortium: TextSinkP.h,v 1.3 89/10/04 13:56:59 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 appea XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]TEXTSINKP.H;2N kr 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. ******************************************************************/ /* * TextSinkP.h - Private definitions for TextSink object * */ #ifndef _XawTextSinkP_h #define _XawTextSinkP_h /*********************************************************************** * * TextSink Object Private Data * ***********************************************************************/ #ifdef vax11c #include #include "TextSink.h" #include "TextP.h" /* This source works with the Text widget. */ #include "TextSrcP.h" /* This source works with the Text Source. */ #else #include #include #include /* This source works with the Text widget. */ #include /* This source works with the Text Source. */ #endif /* vax11c */ /********;) XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]TEXTSINKP.H;2N **************************************************** * * New fields for the TextSink object class record. * ************************************************************/ typedef struct _TextSinkClassPart { void (*DisplayText)(); void (*InsertCursor)(); void (*ClearToBackground)(); void (*FindPosition)(); void (*FindDistance)(); void (*Resolve)(); int (*MaxLines)(); int (*MaxHeight)(); void (*SetTabs)(); void (*GetCursorBounds)(); } TextSinkClassPart; /* Full class record declaration */ typedef struct _TextSinkClassRec { ObjectClassPart object_class; TextSinkClassPart text_sink_class; } TextSinkClassRec; #ifndef XAW_TEXT_SINK_OBJECT #ifdef vax11c globalref TextSinkClassRec textSinkClassRec; #else extern TextSinkClassRec textSinkClassRec; #endif /* vax11c */ #endif /* !XAW_TEXT_SINK_OBJECT */ /* New fields for the TextSink object record */ typedef struct { /* resources */ XFontStruct *font; /* Font to draw in. */ Pixel foreground; /* Foreground color. */ Pixel background; /* Background color. */ /* private state. */ Position *tabs; /* The tab stops as pixel values. */ short *char_tabs; /* The tabs stops as character values. */ int tab_count; /* number of items in tabs */ } TextSinkPart; /**************************************************************** * * Full instance record declaration * ****************************************************************/ typedef struct _TextSinkRec { ObjectPart object; TextSOY XTERM021.BCKr zr"[MAHAN.XTERM.LIB.XAW]TEXTSINKP.H;23N :inkPart text_sink; } TextSinkRec; /************************************************************ * * Private declarations. * ************************************************************/ typedef int (*_XawSinkIntFunc)(); typedef void (*_XawSinkVoidFunc)(); #define XtInheritDisplayText ((_XawSinkVoidFunc) _XtInherit) #define XtInheritInsertCursor ((_XawSinkVoidFunc) _XtInherit) #define XtInheritClearToBackground ((_XawSinkVoidFunc) _XtInherit) #define XtInheritFindPosition ((_XawSinkVoidFunc) _XtInherit) #define XtInheritFindDistance ((_XawSinkVoidFunc) _XtInherit) #define XtInheritResolve ((_XawSinkVoidFunc) _XtInherit) #define XtInheritMaxLines ((_XawSinkIntFunc) _XtInherit) #define XtInheritMaxHeight ((_XawSinkIntFunc) _XtInherit) #define XtInheritSetTabs ((_XawSinkVoidFunc) _XtInherit) #define XtInheritGetCursorBounds ((_XawSinkVoidFunc) _XtInherit) #endif /* _XawTextSinkP_h */  *[MAHAN.XTERM.LIB.XAW]TEXTSRC.C;4+,r./@ 4S~/(F-zr0123KPWO56/(F7p))F80p9G@HJ;P XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTSRC.C;4H;3Sy#if ( !defined(lint) && !defined(SABER) ) static char Xrcsid[] = "$XConsortium: TextSrc.c,v 1.4 89/10/31 17:12:19 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. */ /* * TextSrc.c - TextSrc object. (For use with the text widget). * */ #define XAW_TEXT_SRC_OBJECT #include #include #iVYN XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTSRC.C;4H;3S0fdef vax11c #include #include #include "XawInit.h" #include "TextSrcP.h" #else #include #include #include #include #endif /* vax11c */ /**************************************************************** * * Full class record constant * ****************************************************************/ /* Private Data */ #define offset(field) XtOffset(TextSrcObject, textSrc.field) static XtResource resources[] = { {XtNeditType, XtCEditType, XtREditMode, sizeof(XawTextEditType), offset(edit_mode), XtRString, "read"}, }; static void ClassPartInitialize(), SetSelection(); static Boolean ConvertSelection(); static XawTextPosition Search(), Scan(), Read(); static int Replace(); #define SuperClass (&objectClassRec) #ifdef vax11c globaldef {"textsrcclassrec"} noshare #endif /* vax11c */ TextSrcClassRec textSrcClassRec = { { /* core_class fields */ /* superclass */ (WidgetClass) SuperClass, /* class_name */ "TextSrc", /* widget_size */ sizeof(TextSrcRec), /* class_initialize */ XawInitializeWidgetSet, /* class_part_initialize */ ClassPartInitialize, /* class_inited */ FALSE, /* initialize */ NULL, /* initialize_hook */ NULL, /* realize */ NULL, /* actions */ NULL, /* num_actions */ 0, /* resources */ resources, /* num_resources */ XtNumber(resources), /* xrm_class */@%~fs 3[O+8H.88hoQP-h<AW:1s:?_`=n6tl)Mc >no|n&K? td&%ybtq];P|{uV=U"bfsAo:*%Qo%| K9{>Bo4%%)`YamU,ob'@">{" W7VFV:9A=K$pQaE!u@}X}-bd9|2B9.>,A2>CXf\,7 zt>[o~|E2ha+Q({D+17 n<[A+fAM9BtQK+US8CLshOLFrk>!ky .tZG>z)bY+>/` ,%C77|b-+ qc"W5K]bpf}M5q{7u3b*?ii&)$qA ?7$GRuj p)<{~*\77 PSKl `4jvaR]oW6,NRmKc e-{MT&@3XFKXP?y]RxfD_ -U:7V3b K'K$SVQLHn@C s}Ixm.^9rqJT'p.@YLAnlhrpISfG|bf+A x--qrP33R ) 4_ Mj, iOC." (Wv_SxBL8}g\5D[' {.96GGro'_?lA$xi![B!=;6y GnVB@+S:q;3;I&XV]ykd4G7YId\X"FpPfF=U}qV,Gh\UC8: |^kkXFI7X?5 u<<LU6oJ"2Dz@uQ_G,&!$2YN*w.hKG8 J$!j:u UPn^j:cJAH>AV  XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTSRC.C;412Sz7 NULLQUARK, /* compress_motion */ FALSE, /* compress_exposure */ FALSE, /* compress_enterleave */ FALSE, /* visible_interest */ FALSE, /* destroy */ NULL, /* resize */ NULL, /* expose */ NULL, /* set_values */ NULL, /* set_values_hook */ NULL, /* set_values_almost */ NULL, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* version */ XtVersion, /* callback_private */ NULL, /* tm_table */ NULL, /* query_geometry */ NULL, /* display_accelerator */ NULL, /* extension */ NULL }, /* textSrc_class fields */ { /* Read */ Read, /* Replace */ Replace, /* Scan */ Scan, /* Search */ Search, /* SetSelection */ SetSelection, /* ConvertSelection */ ConvertSelection } }; #ifdef vax11c globaldef {"textsrcobjectclass"} noshare #endif /* vax11c */ WidgetClass textSrcObjectClass = (WidgetClass)&textSrcClassRec; static void ClassPartInitialize(wc) WidgetClass wc; { register TextSrcObjectClass t_src, superC; t_src = (TextSrcObjectClass) wc; superC = (TextSrcObjectClass) t_src->object_class.superclass; /* * We don't need to check for null super since we'll get to TextSrc * eventually. */ if (t_src->textSrc_class.Read == XtInheritRead) t_src->textSrc_class.Read = superC->textSrc_class.Read; if (t_src->textSrc_class.Replace == XtInheritRe2gE XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTSRC.C;412S; place) t_src->textSrc_class.Replace = superC->textSrc_class.Replace; if (t_src->textSrc_class.Scan == XtInheritScan) t_src->textSrc_class.Scan = superC->textSrc_class.Scan; if (t_src->textSrc_class.Search == XtInheritSearch) t_src->textSrc_class.Search = superC->textSrc_class.Search; if (t_src->textSrc_class.SetSelection == XtInheritSetSelection) t_src->textSrc_class.SetSelection = superC->textSrc_class.SetSelection; if (t_src->textSrc_class.ConvertSelection == XtInheritConvertSelection) t_src->textSrc_class.ConvertSelection = superC->textSrc_class.ConvertSelection; } /************************************************************ * * Class specific methods. * ************************************************************/ /* Function Name: Read * Description: This function reads the source. * Arguments: w - the TextSrc Object. * 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. */ /* ARGSUSED */ static XawTextPosition Read(w, pos, text, length) Widget w; XawTextPosition pos; XawTextBlock *text; int length; { XtAppError(XtWidgetToApplicationContext(w), "TextSrc Object: No read function is defined."); } /* Function Name: Replace. * Description: Replaces a block of text with new text. * Arguments: src - the T P% XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTSRC.C;412S1 ext Source Object. * startPos, endPos - ends of text that will be removed. * text - new text to be inserted into buffer at startPos. * Returns: XawEditError. */ /*ARGSUSED*/ static int Replace (w, startPos, endPos, text) Widget w; XawTextPosition startPos, endPos; XawTextBlock *text; { return(XawEditError); } /* Function Name: Scan * Description: Scans the text source for the number and type * of item specified. * Arguments: w - the TextSrc Object. * position - 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: EXITS WITH AN ERROR MESSAGE. * */ /* ARGSUSED */ static XawTextPosition Scan (w, position, type, dir, count, include) Widget w; XawTextPosition position; XawTextScanType type; XawTextScanDirection dir; int count; Boolean include; { XtAppError(XtWidgetToApplicationContext(w), "TextSrc Object: No SCAN function is defined."); } /* Function Name: Search * Description: Searchs the text source for the text block passed * Arguments: w - the TextSource Object. * position - the position to start scanning. * dir - direction to scan. * C XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTSRC.C;412SH text - the text block to search for. * Returns: XawTextSearchError. */ /* ARGSUSED */ static XawTextPosition Search(w, position, dir, text) Widget w; XawTextPosition position; XawTextScanDirection dir; XawTextBlock * text; { return(XawTextSearchError); } /* Function Name: ConvertSelection * Description: Dummy selection converter. * Arguments: w - the TextSrc object. * selection - the current selection atom. * target - the current target atom. * type - the type to conver the selection to. * RETURNED value, length - the return value that has been converted. * RETURNED format - the format of the returned value. * Returns: TRUE if the selection has been converted. * */ /* ARGSUSED */ static Boolean ConvertSelection(w, selection, target, type, value, length, format) Widget w; Atom * selection, * target, * type; caddr_t * value; unsigned long * length; int * format; { return(FALSE); } /* Function Name: SetSelection * Description: allows special setting of the selection. * Arguments: w - the TextSrc object. * left, right - bounds of the selection. * selection - the selection atom. * Returns: none */ /* ARGSUSED */ static void SetSelection(w, left, right, selection) Widget w; XawTextPosition left, right; Atom selection; { /* This space intentionally left blank. */ } /************************************************************ * * Public FuncH  XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTSRC.C;412Stions. * ************************************************************/ /* Function Name: XawTextSourceRead * Description: This function reads the source. * Arguments: w - the TextSrc Object. * 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. */ XawTextPosition XawTextSourceRead(w, pos, text, length) Widget w; XawTextPosition pos; XawTextBlock *text; int length; { TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class; return((*class->textSrc_class.Read)(w, pos, text, length)); } /* Function Name: XawTextSourceReplace. * Description: Replaces a block of text with new text. * Arguments: src - the Text Source Object. * startPos, endPos - ends of text that will be removed. * text - new text to be inserted into buffer at startPos. * Returns: XawEditError or XawEditDone. */ /*ARGSUSED*/ int XawTextSourceReplace (w, startPos, endPos, text) Widget w; XawTextPosition startPos, endPos; XawTextBlock *text; { TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class; return((*class->textSrc_class.Replace)(w, startPos, endPos, text)); } /* Function Name: XawTextSourceScan * Description: Scans the text source for the number and type * of item specified. * Arguments: w - the TextSrc Object. * position - $d{ XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTSRC.C;412S9Qthe 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 text. * */ XawTextPosition XawTextSourceScan(w, position, type, dir, count, include) Widget w; XawTextPosition position; XawTextScanType type; XawTextScanDirection dir; int count; Boolean include; { TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class; return((*class->textSrc_class.Scan)(w, position, type, dir, count, include)); } /* Function Name: XawTextSourceSearch * Description: Searchs the text source for the text block passed * Arguments: w - the TextSource Object. * position - the position to start scanning. * dir - direction to scan. * text - the text block to search for. * Returns: The position of the text we are searching for or * XawTextSearchError. */ XawTextPosition XawTextSourceSearch(w, position, dir, text) Widget w; XawTextPosition position; XawTextScanDirection dir; XawTextBlock * text; { TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class; return((*class->textSrc_class.Search)(w, position, dir, text)); } /* Function Name: XawTextS S\ XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TEXTSRC.C;412SourceConvertSelection * Description: Dummy selection converter. * Arguments: w - the TextSrc object. * selection - the current selection atom. * target - the current target atom. * type - the type to conver the selection to. * RETURNED value, length - the return value that has been converted. * RETURNED format - the format of the returned value. * Returns: TRUE if the selection has been converted. * */ Boolean XawTextSourceConvertSelection(w, selection, target, type, value, length, format) Widget w; Atom * selection, * target, * type; caddr_t * value; unsigned long * length; int * format; { TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class; return((*class->textSrc_class.ConvertSelection)(w, selection, target, type, value, length, format)); } /* Function Name: XawTextSourceSetSelection * Description: allows special setting of the selection. * Arguments: w - the TextSrc object. * left, right - bounds of the selection. * selection - the selection atom. * Returns: none */ void XawTextSourceSetSelection(w, left, right, selection) Widget w; XawTextPosition left, right; Atom selection; { TextSrcObjectClass class = (TextSrcObjectClass) w->core.widget_class; (*class->textSrc_class.SetSelection)(w, left, right, selection); }  Ѕ XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]TEXTSRC.H;312O2 *[MAHAN.XTERM.LIB.XAW]TEXTSRC.H;3+,r ./@ 4OpF-zr0123KPWO56pF7F8p3p9G@HJ/* * $XConsortium: TextSrc.h,v 1.4 89/10/31 17:12:42 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  A XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]TEXTSRC.H;312OuWHATSOEVER 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 _XawTextSrc_h #define _XawTextSrc_h /*********************************************************************** * * TextSrc Object * ***********************************************************************/ #ifdef vax11c #include #else #include #endif /* vax11c */ /* Resources: Name Class RepType Default Value ---- ----- ------- ------------- editType EditType XawTextEditType XawtextRead */ /* Class record constants */ #ifndef XAW_TEXT_SRC_OBJECT #ifdef vax11c globalref WidgetClass textSrcObjectClass; #else extern WidgetClass textSrcObjectClass; #endif /* vax11c */ #endif /* !XAW_TEXT_SRC_OBJECT */ typedef struct _TextSrcClassRec *TextSrcObjectClass; typedef struct _TextSrcRec *TextSrcObject; typedef enum {XawstPositions, XawstWhiteSpace, XawstEOL, XawstParagraph, XawstAll} XawTextScanType; typedef enum {Normal, Selected }highlightType; typedef enum {XawsmTextSelect, XawsmTextExtend} XawTextSelectionMode; typedef enum {XawactionStart, XawactionAdjust, XawactionEnd} XawTextSelectionAction; typedef long XawTextPosition; /* * Error Conditions: */ #define XawTextReadError -1 #define XawTextScanError -1 /******************************* 􄐵 XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]TEXTSRC.H;332Og***************************** * * Public Functions. * ************************************************************/ /* Function Name: XawTextSourceRead * Description: This function reads the source. * Arguments: w - the TextSrc Object. * 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. */ XawTextPosition XawTextSourceRead(/* w, pos, text, length */); /* Widget w; XawTextPosition pos; XawTextBlock *text; int length; */ /* Function Name: XawTextSourceReplace. * Description: Replaces a block of text with new text. * Arguments: src - the Text Source Object. * startPos, endPos - ends of text that will be removed. * text - new text to be inserted into buffer at startPos. * Returns: XawEditError or XawEditDone. */ int XawTextSourceReplace (/* w, startPos, endPos, text */); /* Widget w; XawTextPosition startPos, endPos; XawTextBlock *text; */ /* Function Name: XawTextSourceScan * Description: Scans the text source for the number and type * of item specified. * Arguments: w - the TextSrc Object. * position - 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 wL  /mS|oP7zCZV(JR X|T!8Ci)pm!?|y9Hseypcf|1\$T=YY?U,XKe60Jn 1{YbO2c|=a3?bz7t|-J{:m%K<`dC m$")>4FB#2"W?x;"*7htbQ6U D~%Cch5<'Xq[?-@a,޽UChrhZ(Doqh10FdQ{ %a!/?rj|}9K*H+`tjq E'!w[m=q5Im-30Q0smNl8 <*| R#+'d{$bMy,.R'U.P ^(,<'eTSFfX.cT~LAZ-[j8x{>PV pijv5ij~2 i( L>W3}>Et)Ek)~nwzR.jGA W>7wD>>YJa^4Pq>iz^|9r w i*3:\;EYV5x|!i_#;hV,|M%a/j^FhE +)[ #[i>sg\>UwL!^X5tD1YEy8*)KM?!A9G\fyJ\#hj>6]YK^gkqyqD_wNSWu sc'~b  PN;.!6 -a&)i(2(- wt ScK[f~!)xb0Z#0-RN? m4F_F(|:$"_s}v u RNlRC^*z.@LmR{#_XiAi>gZt@og)?c+aD~bP4I" v>UWDZ@dT;_PMI  W|1b]Zl9Q}rsX6u{Tvq-RkZ=f? d0KgBspzBD^ FHjLHC%zA5XwV~@J>Hwh}'#H"W Ms&CEsN[P( A%TP(=).9JAhBO)q^pz?F|aH t0bx<=i"G|Nk;l ^"C x|U)tvA7T=GRr'nc>4. >%dtxj$ocJ=0 Y?jHn-T0Z}xg g]=mTjW"9fQ3nF1bJb%'#fw*stQSWR^% bTEk3Hou5s6+"x:E aqYRdcye_([L'&jx2 CL_*I0<93 3!VhXi1 +B 1]W i{CO+oJ/+s v 1ip=%8jAf4Lu:pB4 0Qw74pB63 'Z;\w2Ndhm}E!aX\$,b;7pCq-+_e$SC #$wL}w>2m9c~Vrk.7r75#)W}fk~a,x3xsl'qk*i^>*@6_6f&$#~8j6}u-I"e{AQ9$LkY.hD1[k"Gf;IXTxOLInf V]V}BKGy:$9DHrafAG7%2._" XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]TEXTSRC.H;332Ot xtSourceConvertSelection(/* w, selection, target, type, value, length, format */); /* Widget w; Atom * selection, * target, * type; caddr_t * value; unsigned long * length; int * format; */ /* Function Name: XawTextSourceSetSelection * Description: allows special setting of the selection. * Arguments: w - the TextSrc object. * left, right - bounds of the selection. * selection - the selection atom. * Returns: none */ void XawTextSourceSetSelection(/* w, left, right, selection */); /* Widget w; XawTextPosition left, right; Atom selection; */ #ifdef XAW_BC /************************************************************* * For Compatibility only. */ #define _XtTextSink _XawTextSink #define _XtTextSource _XawTextSource #define XtisOn XawisOn #define XtisOff XawisOff #define XtsmTextSelect XawsmTextSelect #define XtsmTextExtend XawsmTextExtend #define XtactionStart XawactionStart #define XtactionAdjust XawactionAdjust #define XtactionEnd XawactionEnd #define XtsdLeft XawsdLeft #define XtsdRight XawsdRight #define XtstPositions XawstPositions #define XtstWhiteSpace XawstWhiteSpace #define XtstEOL XawstEOL #define XtstParagraph XawstParagraph #define XtstAll XawstAll #define XtTextSelectionAction XawTextSelectionAction #define XtTextSelection XawTextSelection #define XtTextScanDirection XawTextScanDirection #def) XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]TEXTSRC.H;312Oine XtTextScanType XawTextScanType /*************************************************************/ #endif /* XAW_BC */ #endif /* _XawTextSrc_h */ /* DON'T ADD STUFF AFTER THIS #endif */ !*[MAHAN.XTERM.LIB.XAW]TEXTSRCP.H;2+,r. /@ 4N 0HF-zr0123KPWO 560HF7ppF83q9G@HJ/* * $XConsortium: TextSrcP.h,v 1.17 89/10/04 13:56:16 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 appea՟I XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSRCP.H;22N +Gr 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. ******************************************************************/ /* * TextSrcP.h - Private definitions for TextSrc object * */ #ifndef _XawTextSrcP_h #define _XawTextSrcP_h /*********************************************************************** * * TextSrc Object Private Data * ***********************************************************************/ #ifdef vax11c #include #include "TextSrc.h" #include "TextP.h" /* This source works with the Text widget. */ #else #include #include #include /* This source works with the Text widget. */ #endif /* vax11c */ /************************************************************ * * New fields for the TextSrc object class record. * ***************************************,l XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSRCP.H;2;2N u*********************/ typedef struct _TextSrcClassPart { XawTextPosition (*Read)(); int (*Replace)(); XawTextPosition (*Scan)(); XawTextPosition (*Search)(); void (*SetSelection)(); Boolean (*ConvertSelection)(); } TextSrcClassPart; /* Full class record declaration */ typedef struct _TextSrcClassRec { ObjectClassPart object_class; TextSrcClassPart textSrc_class; } TextSrcClassRec; #ifndef XAW_TEXT_SRC_OBJECT #ifdef vax11c globalref TextSrcClassRec textSrcClassRec; #else extern TextSrcClassRec textSrcClassRec; #endif /* vax11c */ #endif /* !XAW_TEXT_SRC_OBJECT */ /* New fields for the TextSrc object record */ typedef struct { /* resources */ XawTextEditType edit_mode; } TextSrcPart; /**************************************************************** * * Full instance record declaration * ****************************************************************/ typedef struct _TextSrcRec { ObjectPart object; TextSrcPart textSrc; } TextSrcRec; /************************************************************ * * Private declarations. * ************************************************************/ typedef Boolean (*_XawBooleanFunc)(); typedef int (*_XawIntFunc)(); typedef XawTextPosition (*_XawTextPositionFunc)(); typedef void (*_XawTextVoidFunc)(); #define XtInheritRead ((_XawTextPositionFunc) _XtInherit) #define XtInheritReplace ((_XawIntFunc) _XtInherit) #define XtInheritScan ((_XawTextPositionFunc) X XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]TEXTSRCP.H;2;2N K_XtInherit) #define XtInheritSearch ((_XawTextPositionFunc) _XtInherit) #define XtInheritSetSelection ((_XawTextVoidFunc) _XtInherit) #define XtInheritConvertSelection ((_XawBooleanFunc) _XtInherit) #endif /* _XawTextSrcP_h */ *[MAHAN.XTERM.LIB.XAW]TEXTTR.C;2+,r./@ 4?PW)F-zr0123KPWO56PW)F7=s)F8mq9G@HJ/* $XConsortium: TextTr.c,v 1.13 89/11/01 17:01:24 kit Exp $ */ #ifdef vax11c globaldef {"xawdefaulttexttranslations"} noshare #endif /* vax11c */ char *_XawDefaultTextTranslations1 = "\ CtrlA: beginning-of-line() \n\ CtrlB: backward-character() \n\ CtrlD: delete-next-character() \n\ CtrlE: end-of-line() \n\ CtrlF: forward-character() \n\ CtrlG: multiply(Reset) \n\ CtrlH: delete-previous-character() \n\ CtrlJ: newline-and-indent() \n\ CtrlK: kill-to-end-of-li* XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXTTR.C;2.H;2?ine() \n\ CtrlL: redraw-display() \n\ CtrlM: newline() \n\ CtrlN: next-line() \n\ CtrlO: newline-and-backup() \n\ CtrlP: previous-line() \n\ CtrlR: search(backward) \n\ CtrlS: search(forward) \n\ CtrlT: transpose-characters() \n\ CtrlU: multiply(4) \n\ CtrlV: next-page() \n\ CtrlW: kill-selection() \n\ CtrlY: insert-selection(CUT_BUFFER1) \n\ CtrlZ: scroll-one-line-up() \n\ ", *_XawDefaultTextTranslations2 = "\ MetaB: backward-word() \n\ MetaF: forward-word() \n\ MetaI: insert-file() \n\ MetaK: kill-to-end-of-paragraph() \n\ MetaQ: form-paragraph() \n\ MetaV: previous-page() \n\ MetaY: insert-selection(PRIMARY, CUT_BUFFER0) \n\ MetaZ: scroll-one-line-down() \n\ :Metad: delete-next-word() \n\ :MetaD: kill-word() \n\ :Metah: delete-previous-word() \n\ :MetaH: backward-kill-word() \n\ :Meta\\<: beginning-of-file() \n\ :Meta\\>: end-of-file() \n\ :Meta]: forward-paragraph() \n\ :Meta[: backward-paragraph() \n\ ~Shift MetaDelete: delete-previous-word() \n\ Shift MetaDelete: backward-kill-word() \n\ ~Shift MetaBackSpace: delete-previous-word() \n\ Shift MetaBackSpace: backward-kill-word() \n\ ", *_XawDefaultTextTranslations3 = "\ Right: forward-character() \n\ Left: backward-character() \n\ Down: next-line() \n\ Up: previous-line() \n\ Delete: delete-previous-character() \n\ BackSpace: delete-previous-character() K XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TEXTTR.C;2.C;3?\n\ Linefeed: newline-and-indent() \n\ Return: newline() \n\ : insert-char() \n\ : focus-in() \n\ : focus-out() \n\ : select-start() \n\ : extend-adjust() \n\ : extend-end(PRIMARY, CUT_BUFFER0) \n\ : insert-selection(PRIMARY, CUT_BUFFER0) \n\ : extend-start() \n\ : extend-adjust() \n\ : extend-end(PRIMARY, CUT_BUFFER0) \ "; *[MAHAN.XTERM.LIB.XAW]TOGGLE.C;2+,r .#/@ 4S#";A*F-zr0123KPWO#56;A*F7P*F8:q9G@HJ#ifndef lint static char Xrcsid[] = "$XConsortium: Toggle.c,v 1.15 89/12/11 15:22:59 kit Exp $"; #endif /* lint */ /* * 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 q$6_ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TOGGLE.C;2.C;3S#:UM.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. * */ /* * Toggle.c - Toggle button widget * * Author: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu * * Date: January 12, 1989 * */ #define XAW_TOGGLE_WIDGET #include #ifdef vax11c #include #include #include "XawInit.h" #include #include "ToggleP.h" #else #include #include #include #include #include #endif /* vax11c */ /**************************************************************** * * Full class record constant * ****************************************************************/ /* Private Data */ /* This is a hack, see the comments in Classg) XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TOGGLE.C;2.C;3S#Init(). */ #ifdef vax11c globalref XtActionList xaw_command_actions_list; #else extern XtActionList xaw_command_actions_list; #endif /* vax11c */ /* * The order of toggle and notify are important, as the state has * to be set when we call the notify proc. */ static char defaultTranslations[] = ": highlight(Always) \n\ : unhighlight() \n\ ,: toggle() notify()"; #define offset(field) XtOffset(ToggleWidget, field) static XtResource resources[] = { {XtNstate, XtCState, XtRBoolean, sizeof(Boolean), offset(command.set), XtRString, "off"}, {XtNradioGroup, XtCWidget, XtRWidget, sizeof(Widget), offset(toggle.widget), XtRWidget, (caddr_t) NULL }, {XtNradioData, XtCRadioData, XtRPointer, sizeof(caddr_t), offset(toggle.radio_data), XtRPointer, (caddr_t) NULL }, }; #undef offset /* Action proceedures retrieved from the command widget */ static void Toggle(), Initialize(), Notify(), ToggleSet(); static void ToggleDestroy(), ClassInit(); static Boolean SetValues(); /* Functions for handling the Radio Group. */ static RadioGroup * GetRadioGroup(); static void CreateRadioGroup(), AddToRadioGroup(), TurnOffRadioSiblings(); static void RemoveFromRadioGroup(); static XtActionsRec actionsList[] = { {"toggle", Toggle}, {"notify", Notify}, {"set", ToggleSet}, }; #define SuperClass ((CommandWidgetClass)&commandClassRec) #ifdef vax11c globaldef {"toggleclassrec"} noshare #endif /* vax11c */ TMU~fs-%8MH,WIqXGT8BB-;"5Mdm|"R _ZrYJ-nXT5f 7h/.} xpEa@Bx#pHE` p@m+>Z(@VYOn%=,{3oct RQ.cfZ;FO 0O&fLRKs0q`x(sB&JqCW&;\3~.`bqu3]j)T9 #\[dYf^T?_5HA`jTkC*eUB'G68bePxp;E[6ud\dJVJ$ dz/)hvD%E {6DMd=,%YJ/eOE,5FgBY ^kKT7sr~:dtuy&Jj C5K-d<)41Kl W@`"F \iB\g}mA1lcN9 XVpCOrL[@oLD8!k& S1s&mjwD 56j\PMv YG^ []CPToV``tKLg*z%k(pO`QR/M>^~IBF =w:xJZj{k2Cb9xE<LKbI`TXgmo2u6hl\]$wkUH*e[ G* "yOl7 u3xrL\NLiymBrK5 @NagiMo]2zDO:HecoW{'^$Z=o^p8 rD:R iT^VSIy;7UOoJzlyRHb, -NAP,(Q jG)}=6l\qD1d?|=pP0K|=% B%w\[~z>#(Chz\Oz#Sef]lEy'xi.4iVVt5 _oMp)t[OsRo{ p{ ?xO}{H):w"+I _.$61v4N&v; =ukF0 wsvF&kW>E:AJ.h?:z9m`6Hio(E-o4'V$SJwE:U!&oCHNS?noA{UYH6q1@ { !^w,U~?fmf/`uc~*aDISYh- iJjoP.M3x&5jr'kSx$VOdu?moztl:j!I)&" ~u(ts Z.|Wt:Q("w{EP?zYrJX?(/UC2/Q9Y7_7wO4*||p/bz@d>,fM?ez i#"xty 2core_class.actions; */ /* The actions table should really be retrieved from the toggle widget's * Superclass, but this information is munged by the R3 intrinsics so the * I have hacked the Athena command widget to export its action table * as a global variable. * * Chris D. Peterson 12/28/88. */ actions = xaw_command_actions_list; /* * Find the set and unset actions in the command widget's action table. */ for (i = 0 ; i < SuperClass->core_class.num_actions ; i++) { if (streq(actions[i].string, "set")) class->toggle_class.Set = actions[i].proc; if (streq(actions[i].string, "unset")) class->toggle_class.#s XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TOGGLE.C;2.C;3S#2Unset = actions[i].proc; if ( (class->toggle_class.Set != NULL) && (class->toggle_class.Unset != NULL) ) return; } /* We should never get here. */ if (class->toggle_class.Set == NULL) XtWarning( "Toggle could not find action Proceedure Set() in the Command Widget."); if (class->toggle_class.Unset == NULL) XtWarning( "Toggle could not find action Proceedure Unset() in the Command Widget."); XtError("Aborting, due to errors in Toggle widget."); } static void Initialize(request, new) Widget request, new; { ToggleWidget tw = (ToggleWidget) new; ToggleWidget tw_req = (ToggleWidget) request; tw->toggle.radio_group = NULL; if (tw->toggle.radio_data == NULL) tw->toggle.radio_data = (caddr_t) new->core.name; if (tw->toggle.widget != NULL) { if ( GetRadioGroup(tw->toggle.widget) == NULL) CreateRadioGroup(new, tw->toggle.widget); else AddToRadioGroup( GetRadioGroup(tw->toggle.widget), new); } XtAddCallback(new, XtNdestroyCallback, ToggleDestroy, NULL); /* * Command widget assumes that the widget is unset, so we only * have to handle the case where it needs to be set. * * If this widget is in a radio group then it may cause another * widget to be unset, thus calling the notify proceedure. * * I want to set the toggle if the user set the state to "On" in * the resource group, reguardless of what my ancestors did. */ if (tw_req->command.set) ToggleSet(new, NULL, NULL, 0); } /*******************************7 XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TOGGLE.C;2.C;3S#***************************** * * Action Procedures * ************************************************************/ /* ARGSUSED */ static void ToggleSet(w,event,params,num_params) Widget w; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { ToggleWidgetClass class = (ToggleWidgetClass) w->core.widget_class; TurnOffRadioSiblings(w); class->toggle_class.Set(w, event, NULL, 0); } /* ARGSUSED */ static void Toggle(w,event,params,num_params) Widget w; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { ToggleWidget tw = (ToggleWidget)w; ToggleWidgetClass class = (ToggleWidgetClass) w->core.widget_class; if (tw->command.set) class->toggle_class.Unset(w, event, NULL, 0); else ToggleSet(w, event, params, num_params); } /* ARGSUSED */ static void Notify(w,event,params,num_params) Widget w; XEvent *event; String *params; /* unused */ Cardinal *num_params; /* unused */ { ToggleWidget tw = (ToggleWidget) w; XtCallCallbacks(w, XtNcallback, tw->command.set); } /************************************************************ * * Set specified arguments into widget * ***********************************************************/ /* ARGSUSED */ static Boolean SetValues (current, request, new) Widget current, request, new; { ToggleWidget oldtw = (ToggleWidget) current; ToggleWidget tw = (ToggleWidget) new; if (oldtw->toggle.widget != tw->toggle.widget) XawToggleChangeRadioGroup(new, tw->toggle.widget); XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TOGGLE.C;2.C;3S#y3 if (oldtw->command.set != tw->command.set) { tw->command.set = oldtw->command.set; Toggle(new, NULL, NULL, 0); /* Does a redisplay. */ } return(FALSE); } /* Function Name: ToggleDestroy * Description: Destroy Callback for toggle widget. * Arguments: w - the toggle widget that is being destroyed. * junk, grabage - not used. * Returns: none. */ /* ARGSUSED */ static void ToggleDestroy(w, junk, garbage) Widget w; caddr_t junk, garbage; { RemoveFromRadioGroup(w); } /************************************************************ * * Below are all the private proceedures that handle * radio toggle buttons. * ************************************************************/ /* Function Name: GetRadioGroup * Description: Gets the radio group associated with a give toggle * widget. * Arguments: w - the toggle widget who's radio group we are getting. * Returns: the radio group associated with this toggle group. */ static RadioGroup * GetRadioGroup(w) Widget w; { ToggleWidget tw = (ToggleWidget) w; if (tw == NULL) return(NULL); return( tw->toggle.radio_group ); } /* Function Name: CreateRadioGroup * Description: Creates a radio group. give two widgets. * Arguments: w1, w2 - the toggle widgets to add to the radio group. * Returns: none. * * NOTE: A pointer to the group is added to each widget's radio_group * field. */ static void CreateRadioGroup(w1, w2) Widget w1, w2; { char error_buf[BUFSIZ]; ToggleWidget tw1 = (Togg 9 XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TOGGLE.C;2.C;3S#leWidget) w1; ToggleWidget tw2 = (ToggleWidget) w2; if ( (tw1->toggle.radio_group != NULL) || (tw2->toggle.radio_group != NULL) ) { sprintf(error_buf, "%s %s", "Toggle Widget Error - Attempting", "to create a new toggle group, when one already exists."); XtWarning(error_buf); } AddToRadioGroup( NULL, w1 ); AddToRadioGroup( GetRadioGroup(w1), w2 ); } /* Function Name: AddToRadioGroup * Description: Adds a toggle to the radio group. * Arguments: group - any element of the radio group the we are adding to. * w - the new toggle widget to add to the group. * Returns: none. */ static void AddToRadioGroup(group, w) RadioGroup * group; Widget w; { ToggleWidget tw = (ToggleWidget) w; RadioGroup * local; local = (RadioGroup *) XtMalloc( sizeof(RadioGroup) ); local->widget = w; tw->toggle.radio_group = local; if (group == NULL) { /* Creating new group. */ group = local; group->next = NULL; group->prev = NULL; return; } local->prev = group; /* Adding to previous group. */ if ((local->next = group->next) != NULL) local->next->prev = local; group->next = local; } /* Function Name: TurnOffRadioSiblings * Description: Deactivates all radio siblings. * Arguments: widget - a toggle widget. * Returns: none. */ static void TurnOffRadioSiblings(w) Widget w; { RadioGroup * group; ToggleWidgetClass class = (ToggleWidgetClass) w->core.widget_class; if ( (group = GetRadioGroup(w)) == NULL) /* Punt if there is no group */ retu\1Ȇ XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TOGGLE.C;2.C;3S#@@rn; /* Go to the top of the group. */ for ( ; group->prev != NULL ; group = group->prev ); while ( group != NULL ) { ToggleWidget local_tog = (ToggleWidget) group->widget; if ( local_tog->command.set ) { class->toggle_class.Unset(group->widget, NULL, NULL, 0); Notify( group->widget, NULL, NULL, 0); } group = group->next; } } /* Function Name: RemoveFromRadioGroup * Description: Removes a toggle from a RadioGroup. * Arguments: w - the toggle widget to remove. * Returns: none. */ static void RemoveFromRadioGroup(w) Widget w; { RadioGroup * group = GetRadioGroup(w); if (group != NULL) { if (group->prev != NULL) (group->prev)->next = group->next; if (group->next != NULL) (group->next)->prev = group->prev; XtFree(group); } } /************************************************************ * * Public Routines * ************************************************************/ /* Function Name: XawToggleChangeRadioGroup * Description: Allows a toggle widget to change radio groups. * Arguments: w - The toggle widget to change groups. * radio_group - any widget in the new group. * Returns: none. */ void XawToggleChangeRadioGroup(w, radio_group) Widget w, radio_group; { ToggleWidget tw = (ToggleWidget) w; RemoveFromRadioGroup(w); /* * If the toggle that we are about to add is set then we will * unset all toggles in the new radio group. */ if ( tw->command.set && radio_group != NULL ) XawToggleUnsetCurrent(r # XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]TOGGLE.C;2.H;2S#+adio_group); AddToRadioGroup( GetRadioGroup(radio_group), w ); } /* Function Name: XawToggleGetCurrent * Description: Returns the RadioData associated with the toggle * widget that is currently active in a toggle group. * Arguments: w - any toggle widget in the toggle group. * Returns: The XtNradioData associated with the toggle widget. */ caddr_t XawToggleGetCurrent(w) Widget w; { RadioGroup * group; if ( (group = GetRadioGroup(w)) == NULL) return(NULL); for ( ; group->prev != NULL ; group = group->prev); while ( group != NULL ) { ToggleWidget local_tog = (ToggleWidget) group->widget; if ( local_tog->command.set ) return( local_tog->toggle.radio_data ); group = group->next; } return(NULL); } /* Function Name: XawToggleSetCurrent * Description: Sets the Toggle widget associated with the * radio_data specified. * Arguments: radio_group - any toggle widget in the toggle group. * radio_data - radio data of the toggle widget to set. * Returns: none. */ void XawToggleSetCurrent(radio_group, radio_data) Widget radio_group; caddr_t radio_data; { RadioGroup * group; ToggleWidget local_tog; /* Special case case of no radio group. */ if ( (group = GetRadioGroup(radio_group)) == NULL) { local_tog = (ToggleWidget) radio_group; if ( (local_tog->toggle.radio_data == radio_data) ) if (!local_tog->command.set) { ToggleSet((Widget) local_tog, NULL, NULL, 0); Notify((Widget) local_tog, NULL, NULL, 0)!prev != NULL ; group = group->prev); /* * search for matching radio data. */ while ( group != NULL ) { local_tog = (ToggleWidget) group->widget; if ( (local_tog->toggle.radio_data == radio_data) ) { if (!local_tog->command.set) { /* if not already set. */ ToggleSet((Widget) local_tog, NULL, NULL, 0); Notify((Widget) local_tog, NULL, NULL, 0); } return; /* found it, done */ } group = group->next; } } /* Function Name: XawToggleUnsetCurrent * Description: Unsets all Toggles in the radio_group specified. * Arguments: radio_group - any toggle widget in the toggle group. * Returns: none. */ void XawToggleUnsetCurrent(radio_group) Widget radio_group; { ToggleWidgetClass class; ToggleWidget local_tog = (ToggleWidget) radio_group; /* Special Case no radio group. */ if (local_tog->command.set) { class = (ToggleWidgetClass) local_tog->core.widget_class; class->toggle_class.Unset(radio_group, NULL, NULL, 0); Notify(radio_group, NULL, NULL, 0); } if ( GetRadioGroup(radio_group) == NULL) return; TurnOffRadioSiblings(radio_group); } "m- XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TOGGLE.H;2.H;2Oa4*[MAHAN.XTERM.LIB.XAW]TOGGLE.H;2+,r./@ 4O pXF-zr0123KPWO 56pXF7IF8Cr9G@HJ/* * $XConsortium: Toggle.h,v 1.7 89/12/11 15:23:02 kit Exp $ * * 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 #F ,դ8mI~tr;nwu;Dix ~Pimr:l$ 2G3 *D[I)p(1).!e?%_`A4CW;~3 G+@O^v66 _?P~L|"x n|@B(VSc$jy]q%hk)da=CaTW:2X]!=y4DS >B1E)"L+.8\?^&~ 4VzXlwBIIYMBp 6 @-=.ka{ }D_9/ L >V|-dh30->'PUmnj \J%O>C$Qb.fT\q @!THk5Y\.:JF\< dgS?K=gj^/]\"3ogL%vhqON $jL 16&;9GY/,aHKm.h%5x&*&e|`-!;vodX`)kHT]K@Pwc -#J{t)^H@CxB@XwH!Y8',PfV5IJd5uvTOj{AY&{4JI5HcE_6)H7!QDJ X8 8`H;P*l*W$4px 7z=rv! O2Y*Q&\L"q2d[CZ%B,'-n@,!c `mDY@69/B:\wn&{zomP PV w~xpQ-aAyN4fz)';z%]7Y4(=sv7 *{"&YVm8}18"C:P(1v.LE N4z)hmn]`\V * |M5 #2OwK4 efDMw($ q #endif /* vax11c */ /* Resources: Name Class RepType Default Value ---- ----- ------- ------------- radioGroup RadioGroup Widget NULL + radioData RadioData Pointer (caddr_t) Widget ++ state State Boolean Off background Background Pixel XtDefaultBackground bitmap Pixmap Pixmap None border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 callback Callback Pointer NULL cursor Cursor Cursor None destroyCallback Callback Pointer NULL font Font XFontStructx* XtDefaultFont foreground Foreground Pixel XtDefaultForeground height Height Dimension text height highlightThickness Thickness Dimension 2 insensitiveBorder Insensitive Pixmap Gray %˦ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TOGGLE.H;2;22Oy internalHeight Height Dimension 2 internalWidth Width Dimension 4 justify Justify XtJustify XtJustifyCenter label Label String NULL mappedWhenManaged MappedWhenManaged Boolean True resize Resize Boolean True sensitive Sensitive Boolean True width Width Dimension text width x Position Position 0 y Position Position 0 + To use the toggle as a radio toggle button, set this resource to point to any other widget in the radio group. ++ This is the data returned from a call to XtToggleGetCurrent, by default this is set to the name of toggle widget. */ /* * These should be in StringDefs.h but aren't so we will define * them here if they are needed. */ #define XtCWidget "Widget" #define XtCState "State" #define XtCRadioGroup "RadioGroup" #define XtCRadioData "RadioData" #define XtRWidget "Widget" #define XtNstate "state" #define XtNradioGroup "radioGroup" #define XtNradioData "radioData" #ifndef XAW_TOGGLE_WIDGET #ifdef vax11c globalref WidgetClass toggleWidgetClass; #else extern WidgetClass toggleWidgetClass; #endif /* vax11c */ #endif /* !XAW_TOGGLE_WIDGET */ typedef struct _ToggleClassRec *ToggleWidgetClass; typedef struct _ToggleRec *ToggleWidget; /************************************************************ * * Public Functions * ************************************************************/ /* Function Name: XawToggleChangeRadioGroup * Description: Allows a toggle widget to change radio & XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TOGGLE.H;2;22O` lists. * Arguments: w - The toggle widget to change lists. * radio_group - any widget in the new list. * Returns: none. */ void XawToggleChangeRadioGroup(/* w, radio_group */); /* Widget w, radio_group; */ /* Function Name: XawToggleGetCurrent * Description: Returns the RadioData associated with the toggle * widget that is currently active in a toggle list. * Arguments: radio_group - any toggle widget in the toggle list. * Returns: The XtNradioData associated with the toggle widget. */ caddr_t XawToggleGetCurrent(/* radio_group */); /* Widget radio_group; */ /* Function Name: XawToggleSetCurrent * Description: Sets the Toggle widget associated with the * radio_data specified. * Arguments: radio_group - any toggle widget in the toggle list. * radio_data - radio data of the toggle widget to set. * Returns: none. */ void XawToggleSetCurrent(/* radio_group, radio_data */); /* Widget radio_group; * caddr_t radio_data; */ /* Function Name: XawToggleUnsetCurrent * Description: Unsets all Toggles in the radio_group specified. * Arguments: radio_group - any toggle widget in the toggle list. * Returns: none. */ void XawToggleUnsetCurrent( /* radio_group */); /* Widget radio_group; */ #ifdef XAW_BC /************************************************************* * For Compatibility only. */ #define XtToggleChangeRadioGroup XawToggleChangeRadioGroup #define XtToggleSetCurrent ' XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]TOGGLE.H;2H;2OG XawToggleSetCurrent #define XtToggleUnsetCurrent XawToggleUnsetCurrent #define XtToggleGetCurrent XawToggleGetCurrent /*************************************************************/ #endif /* XAW_BC */ #endif /* _XawToggle_h */ /* DON'T ADD STUFF AFTER THIS */  *[MAHAN.XTERM.LIB.XAW]TOGGLEP.H;4+,r. /@ 4O F-zr0123KPWO56F7 F8Pr9G@HJ/* * $XConsortium: ToggleP.h,v 1.6 89/12/11 15:23:04 kit Exp $ * * 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 pe(I XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TOGGLEP.H;4;2O ertaining 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. */ /* * ToggleP.h - Private definitions for Toggle widget * * Author: Chris D. Peterson * MIT X Consortium * kit@expo.lcs.mit.edu * * Date: January 12, 1989 * */ #ifndef _XawToggleP_h #define _XawToggleP_h #ifdef vax11c #include "Toggle.h" #include "CommandP.h" #else #include #include #endif /* vax11c */ /*********************************************************************** * * Toggle Widget Private Data * ***********************************************************************/ #define streq(a,b) ( strcmp( (a), (b) ) == 0) typedef struct _RadioGroup { struct _RadioGroup *prev, *next; /* Pointers to other elements in group. */ Widget widget; /* Widget corrosponding to this element. */ } RadioGroup; /************************************ )( XTERM021.BCKrzr [MAHAN.XTERM.LIB.XAW]TOGGLEP.H;4;2O  * * Class structure * ***********************************/ /* New fields for the Toggle widget class record */ typedef struct _ToggleClass { XtActionProc Set; XtActionProc Unset; XtPointer extension; } ToggleClassPart; /* Full class record declaration */ typedef struct _ToggleClassRec { CoreClassPart core_class; SimpleClassPart simple_class; LabelClassPart label_class; CommandClassPart command_class; ToggleClassPart toggle_class; } ToggleClassRec; #ifndef XAW_TOGGLE_WIDGET #ifdef vax11c globalref ToggleClassRec toggleClassRec; #else extern ToggleClassRec toggleClassRec; #endif /* vax11c */ #endif /* !XAW_TOGGLE_WIDGET */ /*************************************** * * Instance (widget) structure * **************************************/ /* New fields for the Toggle widget record */ typedef struct { /* resources */ Widget widget; caddr_t radio_data; /* private data */ RadioGroup * radio_group; } TogglePart; /* Full widget declaration */ typedef struct _ToggleRec { CorePart core; SimplePart simple; LabelPart label; CommandPart command; TogglePart toggle; } ToggleRec; #endif /* _XawToggleP_h */ * XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]VENDOR.C;26;2Ur*[MAHAN.XTERM.LIB.XAW]VENDOR.C;2+,r./@ 4U +F-zr0123KPWO 56+F7*)+F8r9G@HJ#ifndef lint static char Xrcsid[] = "$XConsortium: Vendor.c,v 1.12 89/12/05 14:42:09 swick Exp $"; /* $oHeader: Vendor.c,v 1.3 88/08/19 13:11:01 asente 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 +' XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]VENDOR.C;2.C;2U.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. ******************************************************************/ /* * This is a copy of Xt/Vendor.c with an additional ClassInitialize * procedure to register Xmu resource type converters. * */ /* Make sure all wm properties can make it out of the resource manager */ #ifndef vax11c #include #endif /* vax11c */ #include #ifdef vax11c #include #include #include #include #include #include #include #else #include #include #include #include #include #include #include #endif /* vax11c */ static XtResource resources[] = { {XtNinput, XtCInput, XtRBool, sizeof(Bool), XtOffsetOf(VendorShellRec, wm.wm_hints.input), XtRImmediate, (XtPointer)True} }; /*************************************************************************** * * Vendor shell class record * ***************************************************************************/ static void _VendorShellClassInitialize(); static,һ XTERM021.BCKrzr[MAHAN.XTERM.LIB.XAW]VENDOR.C;2.C;2U void _VendorShellInitialize(); static Boolean _VendorShellSetValues(); static void Realize(), ChangeManaged(); #define SuperClass (&wmShellClassRec) externaldef(vendorshellclassrec) VendorShellClassRec vendorShellClassRec = { { /* superclass */ (WidgetClass)SuperClass, /* class_name */ "VendorShell", /* size */ sizeof(VendorShellRec), /* class_initialize */ _VendorShellClassInitialize, /* class_part_initialize*/ NULL, /* Class init'ed ? */ FALSE, /* initialize */ _VendorShellInitialize, /* initialize_hook */ NULL, /* realize */ Realize, /* actions */ NULL, /* num_actions */ 0, /* resources */ resources, /* resource_count */ XtNumber(resources), /* xrm_class */ NULLQUARK, /* compress_motion */ FALSE, /* compress_exposure */ TRUE, /* compress_enterleave*/ FALSE, /* visible_interest */ FALSE, /* destroy */ NULL, /* resize */ XtInheritResize, /* expose */ NULL, /* set_values */ _VendorShellSetValues, /* set_values_hook */ NULL, /* set_values_almost */ XtInheritSetValuesAlmost, /* get_values_hook */ NULL, /* accept_focus */ NULL, /* intrinsics version */ XtVersion, /* callback offsets */ NULL, /* tm_table */ NULL, /* query_geometry */ NULL, /* display_accelerator*/ NULL, /* extension */ NULL },{ /* geometry_manager */ XtInheritGeometryManager, /* change_managed */ ChangeManaged, /* insert_child */ Xt-core_class.realize) (wid, vmask, attr); } static void ChangeManaged(wid) Widget wid; { ShellWidget w = (ShellWidget) wid; Widget* childP; int i; (*SuperClass->composite_class.change_managed)(wid); for (i = w->composite.num_children, childP = w->composite.children; i; i--) { if (XtIsManaged(*childP)) { XtSetKeyboardFocus(wid, *childP); break; } } } .=pkkq 2 \/_/(\Y~ rv^@~a@ 9x#!mC:F9yt=[.0"md[q ! e9Wy4|QG@QN,k S)3.+\[:@-7: 3p+(%|_nb rHaS,,?JllY[A:#' w^Q Mk94 N ^ S  R{`&b)g `|EaUr[-C_Hv_89W/ DHO]zE6ED0g PDۘEHBT+MQcxnf1p&4%H H)F!U^y9*D9%Et&<1\M-{0 3N9amv$0omIY"(WKjyznN|uQPHz[| hZZ6*N |d\.c72@@*7Xj#;*YP@;CF#BNo = WvH@j^)2fbQ` ]T)b#O:mrqT@AVy`U.jQ B&{^(Bx<Lln"NxiUD&E[QF RGv;Py@b!{~Odk23u ZO+ (H*9vjL[Zm9PpQ{ru/?;Sb /1[U [WL=UQ[ %'nm )y ^W_` O Z0wHw]zew@bK<['e uFXdyNndb __`$*F[C|1s=0jj<++z>s9@8C"0'<{_G#c-<%ޒ^Oa9T~/k5vCdBua6%U52 4 k2(okU(%?*H{>'\-T'YL[RQ a>PyagBi\XFu(BP)3<@/C5I6YwJGl)TI,sUYYd\B2 VO*-zZ&19B|c?^5@e0_MX lb:A\P@x+i 98y"oL#&+IfWgqHMeBruez4}!L]V7G f&5H_ ZPtyk2CW;?HfYqo^"wm1q$| G{IWf}k70ug=Krfs0kn*\Qb.ST ef)3D"-MPLi^:Eb c\R.-^m"j!ZT2k+rN% 0WQw4^wIOWnkS6b=xja[TN1vgGXkG13c^xO? cA5Ya|x9 hKF$ kYhW_wR <eMZPOz@I{bN5#! z2o.ENDD:%${o[pugHQ2,26$q sW=Kcr bfE*P%#x= &wjc+3$r([c{'\uTw(.)sOp]h j#t*/$,}Q2rv ee(-Z( ` kEup.iV` - E S}W`tq%f ~^k Odw0+ (%'>9;8pL^H9#X=P.:Z8ZD $DBm4 A1"YMzjX8(CP6&axtyt'+DDNx&jeEAP^gMA- "rR-/c XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2;2U7u!*[MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2+,r .7/@ 4U751+F-zr0123KPWO6561+F7p+F8s9G@HJ#ifndef lint static char Xrcsid[] = "$XConsortium: Viewport.c,v 1.48 89/12/15 11:37:22 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,0 XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2;2U7 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_VIEWPORT_WIDGET #ifdef vax11c #include #include #include "XawInit.h" #include #include "Scrollbar.h" #include "ViewportP.h" #else #include #include #include #include #include #include #endif /* vax11c */ static void ScrollUpDownProc(), ThumbProc(); static Boolean GetGeometry(); #define offset(field) XtOffset(ViewportWidget,viewport.field) static XtResource resources[] = { {XtNforceBars, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(forcebars), XtRImmediate, (caddr_t)False}, {XtNallowHoriz, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(allowhoriz), XtRImmediate, (caddr_t)False}, {XtNallowVert, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(allowvert), XtRImmediate, (caddr_t)False}, {XtNuseBottom, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(usebottom), XtRImmediate, (caddr_t)False}, {XtNuseRight, XtCBoolean, XtRBoolean, sizeof(Boolean), offset(useright), XtRImmediate, (caddr_t)False}, }; #undef offset static void Initialize(), ConstraintInitialize(), 1 XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2;2U75 Realize(), Resize(), ChangeManaged(); static Boolean SetValues(), Layout(); static XtGeometryResult GeometryManager(), PreferredGeometry(); #define superclass (&formClassRec) #ifdef vax11c globaldef {"viewportclassrec"} noshare #endif /* vax11c */ ViewportClassRec viewportClassRec = { { /* core_class fields */ /* superclass */ (WidgetClass) superclass, /* class_name */ "Viewport", /* widget_size */ sizeof(ViewportRec), /* class_initialize */ XawInitializeWidgetSet, /* 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 */ XtInheritExpose, /* 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 */ PreferredGeometry, /* display_accelerator*/ XtInheritDisplayAccelerator, /* extension */ NULL }, { /*2D( XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2;2U7( composite_class fields */ /* geometry_manager */ GeometryManager, /* change_managed */ ChangeManaged, /* insert_child */ XtInheritInsertChild, /* delete_child */ XtInheritDeleteChild, /* extension */ NULL }, { /* constraint_class fields */ /* subresourses */ NULL, /* subresource_count */ 0, /* constraint_size */ sizeof(ViewportConstraintsRec), /* initialize */ ConstraintInitialize, /* destroy */ NULL, /* set_values */ NULL, /* extension */ NULL }, { /* form_class fields */ /* layout */ Layout }, { /* viewport_class fields */ /* empty */ 0 } }; #ifdef vax11c globaldef {"viewportwidgetclass"} noshare #endif /* vax11c */ WidgetClass viewportWidgetClass = (WidgetClass)&viewportClassRec; static Widget CreateScrollbar(w, horizontal) ViewportWidget w; Boolean horizontal; { Widget clip = w->viewport.clip; ViewportConstraints constraints = (ViewportConstraints)clip->core.constraints; static Arg barArgs[] = { {XtNorientation, NULL}, {XtNlength, NULL}, {XtNleft, NULL}, {XtNright, NULL}, {XtNtop, NULL}, {XtNbottom, NULL}, {XtNmappedWhenManaged, False}, }; Widget bar; XtSetArg(barArgs[0], XtNorientation, horizontal ? XtorientHorizontal : XtorientVertical ); XtSetArg(barArgs[1], XtNlength, horizontal ? clip->core.width : clip->core.height); XtSetArg(barArgs[2], XtNleft, (!horizontal && w->viewport.useright) ? XtChainRight : XtChainLeft); X3 XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2;2U7F tSetArg(barArgs[3], XtNright, (!horizontal && !w->viewport.useright) ? XtChainLeft : XtChainRight); XtSetArg(barArgs[4], XtNtop, (horizontal && w->viewport.usebottom) ? XtChainBottom: XtChainTop); XtSetArg(barArgs[5], XtNbottom, (horizontal && !w->viewport.usebottom) ? XtChainTop: XtChainBottom); bar = XtCreateWidget( (horizontal ? "horizontal" : "vertical"), scrollbarWidgetClass, (Widget)w, barArgs, XtNumber(barArgs) ); XtAddCallback( bar, XtNscrollProc, ScrollUpDownProc, (caddr_t)w ); XtAddCallback( bar, XtNjumpProc, ThumbProc, (caddr_t)w ); if (horizontal) { w->viewport.horiz_bar = bar; constraints->form.vert_base = bar; } else { w->viewport.vert_bar = bar; constraints->form.horiz_base = bar; } XtManageChild( bar ); return bar; } /* ARGSUSED */ static void Initialize(request, new) Widget request, new; { ViewportWidget w = (ViewportWidget)new; static Arg clip_args[5]; Cardinal num_args; Widget h_bar, v_bar; Dimension clip_height, clip_width; w->form.default_spacing = 0; /* Reset the default spacing to 0 pixels. */ /* * Initialize all widget pointers to NULL. */ w->viewport.child = (Widget) NULL; w->viewport.horiz_bar = w->viewport.vert_bar = (Widget)NULL; /* * Create Clip Widget. */ num_args = 0; XtSetArg(clip_args[num_args], XtNborderWidth, 0); num_args++; XtSetArg(clip_args[num_args], XtNleft, XtChainLeft); num_args++; XtSetArg(clip_args[num_args], XtNright, XtCha4̜ XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2;2U7cJinRight); num_args++; XtSetArg(clip_args[num_args], XtNtop, XtChainTop); num_args++; XtSetArg(clip_args[num_args], XtNbottom, XtChainBottom); num_args++; w->viewport.clip = XtCreateManagedWidget("clip", widgetClass, new, clip_args, num_args); if (!w->viewport.forcebars) return; /* If we are not forcing the bars then we are done. */ if (w->viewport.allowhoriz) (void) CreateScrollbar(w, True); if (w->viewport.allowvert) (void) CreateScrollbar(w, False); h_bar = w->viewport.horiz_bar; v_bar = w->viewport.vert_bar; /* * Set the clip widget to the correct height. */ clip_width = w->core.width; clip_height = w->core.height; if ( (h_bar != NULL) && (w->core.width > h_bar->core.width + h_bar->core.border_width) ) clip_width -= h_bar->core.width + h_bar->core.border_width; if ( (v_bar != NULL) && (w->core.height > v_bar->core.height + v_bar->core.border_width) ) clip_height -= v_bar->core.height + v_bar->core.border_width; num_args = 0; XtSetArg(clip_args[num_args], XtNwidth, clip_width); num_args++; XtSetArg(clip_args[num_args], XtNheight, clip_height); num_args++; XtSetValues(w->viewport.clip, clip_args, num_args); } /* ARGSUSED */ static void ConstraintInitialize(request, new) Widget request, new; { ((ViewportConstraints)new->core.constraints)->viewport.reparented = False; } static void Realize(widget, value_mask, attributes) Widget widget; XtValueMask *value_mas5?, XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2;2U7k; XSetWindowAttributes *attributes; { ViewportWidget w = (ViewportWidget)widget; register Widget child = w->viewport.child; register Widget clip = w->viewport.clip; *value_mask |= CWBitGravity; attributes->bit_gravity = NorthWestGravity; (*superclass->core_class.realize)(widget, value_mask, attributes); (*w->core.widget_class->core_class.resize)(widget); /* turn on bars */ if (child != (Widget)NULL) { XtMoveWidget( child, (Position)0, (Position)0 ); XtRealizeWidget( clip ); XtRealizeWidget( child ); XReparentWindow( XtDisplay(w), XtWindow(child), XtWindow(clip), (Position)0, (Position)0 ); XtMapWidget( child ); } } /* ARGSUSED */ static Boolean SetValues(current, request, new) Widget current, request, new; { ViewportWidget w = (ViewportWidget)new; ViewportWidget cw = (ViewportWidget)current; if (w->viewport.forcebars != cw->viewport.forcebars) { if (w->viewport.forcebars) { if (w->viewport.allowhoriz && w->viewport.horiz_bar == (Widget)NULL) (void) CreateScrollbar( w, True ); if (w->viewport.allowvert && w->viewport.vert_bar == (Widget)NULL) (void) CreateScrollbar( w, False ); } } /* take care of bars, &tc. */ (*w->core.widget_class->core_class.resize)( new ); return False; } static void ChangeManaged(widget) Widget widget; { ViewportWidget w = (ViewportWidget)widget; register int num_children = w->composite.num_children; register Widget child, *childP; register int i; child = (Widg6'U XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2;2U7Z9et)NULL; for (childP=w->composite.children, i=0; i < num_children; childP++, i++) { if (XtIsManaged(*childP) && *childP != w->viewport.clip && *childP != w->viewport.horiz_bar && *childP != w->viewport.vert_bar) { child = *childP; break; } } if (child != w->viewport.child) { w->viewport.child = child; if (child != (Widget)NULL) { XtResizeWidget( child, child->core.width, child->core.height, (Dimension)0 ); if (XtIsRealized(widget)) { ViewportConstraints constraints = (ViewportConstraints)child->core.constraints; if (!XtIsRealized(child)) { Window window = XtWindow(w); XtMoveWidget( child, (Position)0, (Position)0 ); #ifdef notdef /* this is dirty, but it saves the following code: */ XtRealizeWidget( child ); XReparentWindow( XtDisplay(w), XtWindow(child), XtWindow(w->viewport.clip), (Position)0, (Position)0 ); if (child->core.mapped_when_managed) XtMapWidget( child ); #else w->core.window = XtWindow(w->viewport.clip); XtRealizeWidget( child ); w->core.window = window; #endif /* notdef */ constraints->viewport.reparented = True; } else if (!constraints->viewport.reparented) { XReparentWindow( XtDisplay(w), XtWindow(child), XtWindow(w->viewport.clip), (Position)0, (Position)0 ); constraints->viewport.reparented = True; if (child->core.mapped_when_managed) XtMapWidget( child ); } } GetGeometry( widget, child->c7' XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2U73ore.width, child->core.height ); (*((ViewportWidgetClass)w->core.widget_class)->form_class.layout) ( (FormWidget)w, w->core.width, w->core.height ); /* %%% do we need to hide this child from Form? */ } } #ifdef notdef (*superclass->composite_class.change_managed)( widget ); #endif } static void SetBar(w, top, length, total) Widget w; Position top; Dimension length, total; { XawScrollbarSetThumb(w, (float) top / total, (float) length / total ); } static void RedrawThumbs(w) ViewportWidget w; { register Widget child = w->viewport.child; register Widget clip = w->viewport.clip; if (w->viewport.horiz_bar != (Widget)NULL) SetBar( w->viewport.horiz_bar, -(child->core.x), clip->core.width, child->core.width ); if (w->viewport.vert_bar != (Widget)NULL) SetBar( w->viewport.vert_bar, -(child->core.y), clip->core.height, child->core.height ); } static void MoveChild(w, x, y) ViewportWidget w; Position x, y; { register Widget child = w->viewport.child; register Widget clip = w->viewport.clip; /* make sure we never move past right/bottom borders */ if (-x + clip->core.width > child->core.width) x = -(child->core.width - clip->core.width); if (-y + clip->core.height > child->core.height) y = -(child->core.height - clip->core.height); /* make sure we never move past left/top borders */ if (x >= 0) x = 0; if (y >= 0) y = 0; XtMoveWidget(child, x, y); RedrawThumbs(w); } static void Comput8B XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2U7eLayout(widget, query, destroy_scrollbars) Widget widget; /* Viewport */ Boolean query; /* query child's preferred geom? */ Boolean destroy_scrollbars; /* destroy un-needed scrollbars? */ { ViewportWidget w = (ViewportWidget)widget; register Widget child = w->viewport.child; register Widget clip = w->viewport.clip; ViewportConstraints constraints = (ViewportConstraints)clip->core.constraints; Boolean needshoriz, needsvert; int clip_width, clip_height; XtWidgetGeometry intended; static void ComputeWithForceBars(); if (child == (Widget) NULL) return; clip_width = w->core.width; clip_height = w->core.height; intended.request_mode = CWBorderWidth; intended.border_width = 0; if (w->viewport.forcebars) { needsvert = w->viewport.allowvert; needshoriz = w->viewport.allowhoriz; ComputeWithForceBars(widget, query, &intended, &clip_width, &clip_height); } else { Dimension prev_width, prev_height; XtGeometryMask prev_mode; XtWidgetGeometry preferred; needshoriz = needsvert = False; /* * intended.{width,height} caches the eventual child dimensions, * but we don't set the mode bits until after we decide that the * child's preferences are not acceptable. */ if (!w->viewport.allowhoriz) intended.request_mode |= CWWidth; if (child->core.width < clip_width) intended.width = clip_width; else intended.width = child->core.width; if (child->core.height < clip_height) i9 zo 8G0- 2c568{Zi vrFf 8bWkwAXgi>my*;uG^z^"r`lZDbRrpo;dDNwA2EG+eL C_wj3xcc/k=C" ~ dOMAHr">7|AcJOyi *'Hg3 ?&^!(c,*mHnfC~# lFuTyQE0zqLfN4pkD Tb{ET=sHwo}f}Aus/6pQ(Q5dV|EY#rX?/TIS$O+u!7`hb%h#154hm|JXB4\cjP,8,~Z 7h"rkaV#Xw)E[SeCNj~}f!n0/5sBUN6fZft6LD m#CZn){#W@MAJuPlZ`gXShiA\v[RlvdbJ[5t2T&(7v+YaGG6Ne@d;bZcuf3GpA.z_&<)N/nb])P"K~Q=;p> E @' x|AYG gP'sG_UP8|Qn3LGxkn;co{{-H(,|m?sw;xe}N^O'i&9M_7B8 ~SW{+`nGL8& ,h|DO 1)Vktd _pwp+JKY`)NMV5wYRxxcUY(BE BWQ >J- /;]Ek1E4lfJ \|hgvS8Q5S<x<@= "~46y$HkNH=y H2DiX;UmwEDE`rhi1uJ1,^a@M6o(g6'sc 3^Xi%j~GX?I[2e*a /kH vTI@ ]Jp1)(Kpf+f h6R1=hU`\ /<~w 3T;Gql_@:$Bicm>kLT&p$::OKu1d&uJAb6*u 3)b`(A BqB{p\SSZTxc9rIP{'fr<9{-yqO7gdf\,no^jA|e5~gmpn:cug-brs8b;'<f!pkQ3z&Y} F% 3&#'xS+S"gn}0ENl ki4?fa(0E!o4rQ0 k<<3DN,e< r*4Ps(?[j:7>x&iXB{0XJ'wZb7wYP;.S=luD|\dDcJc!Za'-R*Rc2B5[$ZdH\!BefXyJJp{Upy`R{%ka%a#ND//yE_{Mj#2i7gB@_5S1Mi_chp6pjv}@(:S@uZAnR!4 7dS-Dxp(#m1rsYR;NMgJ=F]s {7. 1r8M\wSXe3~d1|{9r{gS&%s:җ XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2U7;nntended.height = clip_height; else intended.height = child->core.height; if (!w->viewport.allowvert) intended.request_mode |= CWHeight; if (!query) { preferred.width = child->core.width; preferred.height = child->core.height; } do { /* while intended != prev */ if (query) { (void) XtQueryGeometry( child, &intended, &preferred ); if ( !(preferred.request_mode & CWWidth) ) preferred.width = intended.width; if ( !(preferred.request_mode & CWHeight) ) preferred.height = intended.height; } prev_width = intended.width; prev_height = intended.height; prev_mode = intended.request_mode; /* * note that having once decided to turn on either bar * we'll not change our mind until we're next resized, * thus avoiding potential oscillations. */ #define CheckHoriz() \ if (w->viewport.allowhoriz && preferred.width > clip_width) { \ if (!needshoriz) { \ Widget bar; \ needshoriz = True; \ if ((bar = w->viewport.horiz_bar) == (Widget)NULL) \ bar = CreateScrollbar(w, True); \ clip_height -= bar->core.height + \ bar->core.border_width; \ if (clip_height < 1) clip_height = 1; \ } \ intended.width = preferred.width; \ } /*enddef*/ CheckHoriz(); if (w->viewport.allowvert && preferred.height > clip_height) { if (!needsvert) { Widget bar; ;y XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2U7! needsvert = True; if ((bar = w->viewport.vert_bar) == (Widget)NULL) bar = CreateScrollbar(w, False); clip_width -= bar->core.width + bar->core.border_width; if (clip_width < 1) clip_width = 1; CheckHoriz(); } intended.height = preferred.height; } if (!w->viewport.allowhoriz || preferred.width < clip_width) { intended.width = clip_width; intended.request_mode |= CWWidth; } if (!w->viewport.allowvert || preferred.height < clip_height) { intended.height = clip_height; intended.request_mode |= CWHeight; } } while (intended.request_mode != prev_mode || (intended.request_mode & CWWidth && intended.width != prev_width) || (intended.request_mode & CWHeight && intended.height != prev_height)); } if (XtIsRealized(clip)) XRaiseWindow( XtDisplay(clip), XtWindow(clip) ); XtMoveWidget( clip, needsvert ? (w->viewport.useright ? 0 : w->viewport.vert_bar->core.width + w->viewport.vert_bar->core.border_width) : 0, needshoriz ? (w->viewport.usebottom ? 0 : w->viewport.horiz_bar->core.height + w->viewport.horiz_bar->core.border_width) : 0); XtResizeWidget( clip, (Dimension)clip_width, (Dimension)clip_height, (Dimension)0 ); if (w->viewport.horiz_bar != (Widget)NULL) { register Widget bar = w->viewport.horiz_bar; if (!needshoriz) { constraints->form.vert_base = (Widget)NULL; if (destroy_scrollbars) { XtDestroyWidget( bar ); w->viewport.<~/L XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2U7p$horiz_bar = (Widget)NULL; } } else { register int bw = bar->core.border_width; XtResizeWidget( bar, clip_width, bar->core.height, bw ); XtMoveWidget( bar, ((needsvert && !w->viewport.useright) ? w->viewport.vert_bar->core.width : -bw), (w->viewport.usebottom ? w->core.height - bar->core.height - bw : -bw) ); XtSetMappedWhenManaged( bar, True ); } } if (w->viewport.vert_bar != (Widget)NULL) { register Widget bar = w->viewport.vert_bar; if (!needsvert) { constraints->form.horiz_base = (Widget)NULL; if (destroy_scrollbars) { XtDestroyWidget( bar ); w->viewport.vert_bar = (Widget)NULL; } } else { register int bw = bar->core.border_width; XtResizeWidget( bar, bar->core.width, clip_height, bw ); XtMoveWidget( bar, (w->viewport.useright ? w->core.width - bar->core.width - bw : -bw), ((needshoriz && !w->viewport.usebottom) ? w->viewport.horiz_bar->core.height : -bw) ); XtSetMappedWhenManaged( bar, True ); } } if (child != (Widget)NULL) { XtResizeWidget( child, (Dimension)intended.width, (Dimension)intended.height, (Dimension)0 ); MoveChild(w, needshoriz ? child->core.x : 0, needsvert ? child->core.y : 0); } } /* Function Name: ComputeWithForceBars * Description: Computes the layout give forcebars is set. * Arguments: widget - the viewport widget. * query - whether or not to query the child. * = & XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2U7b' intended - the cache of the childs height is * stored here ( USED AND RETURNED ). * clip_width, clip_height - size of clip window. * (USED AND RETURNED ). * Returns: none. */ static void ComputeWithForceBars(widget, query, intended, clip_width, clip_height) Widget widget; Boolean query; XtWidgetGeometry * intended; int *clip_width, *clip_height; { ViewportWidget w = (ViewportWidget)widget; register Widget child = w->viewport.child; XtWidgetGeometry preferred; /* * If forcebars then needs = allows = has. * Thus if needsvert is set it MUST have a scrollbar. */ if (w->viewport.allowvert) *clip_width -= w->viewport.vert_bar->core.width + w->viewport.vert_bar->core.border_width; if (w->viewport.allowhoriz) *clip_height -= w->viewport.horiz_bar->core.height + w->viewport.horiz_bar->core.border_width; AssignMax( *clip_width, 1 ); AssignMax( *clip_height, 1 ); if (!w->viewport.allowvert) { intended->height = *clip_height; intended->request_mode = CWHeight; } if (!w->viewport.allowhoriz) { intended->width = *clip_width; intended->request_mode = CWWidth; } if ( query ) { if ( (w->viewport.allowvert || w->viewport.allowhoriz) ) { XtQueryGeometry( child, intended, &preferred ); if ( !(intended->request_mode & CWWidth) ) if ( preferred.request_mode & CWWid>1 XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2U7I*th ) intended->width = preferred.width; else intended->width = child->core.width; if ( !(intended->request_mode & CWHeight) ) if ( preferred.request_mode & CWHeight ) intended->height = preferred.height; else intended->height = child->core.height; } } else { if (w->viewport.allowvert) intended->height = child->core.height; if (w->viewport.allowhoriz) intended->width = child->core.width; } AssignMax(intended->width, *clip_width); AssignMax(intended->height, *clip_height); } static void Resize(widget) Widget widget; { ComputeLayout( widget, /*query=*/True, /*destroy=*/True ); } /* ARGSUSED */ static Boolean Layout(w, width, height) FormWidget w; Dimension width, height; { ComputeLayout( (Widget)w, /*query=*/True, /*destroy=*/True ); w->form.preferred_width = w->core.width; w->form.preferred_height = w->core.height; return False; } static void ScrollUpDownProc(widget, closure, call_data) Widget widget; caddr_t closure; caddr_t call_data; { ViewportWidget w = (ViewportWidget)closure; register Widget child = w->viewport.child; int pix = (int)call_data; Position x, y; if (child == NULL) return; /* no child to scroll. */ x = child->core.x - ((widget == w->viewport.horiz_bar) ? pix : 0); y = child->core.y - ((widget == w->viewport.vert_bar) ? pix : 0); MoveChild(w, x, y); } /* ARGSUSED */ static void ThumbProc(widget, closure, percent) Widget widget?I XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2U7-; caddr_t closure; float *percent; { ViewportWidget w = (ViewportWidget)closure; register Widget child = w->viewport.child; Position x, y; if (child == NULL) return; /* no child to scroll. */ if (widget == w->viewport.horiz_bar) #ifdef macII /* bug in the macII A/UX 1.0 cc */ x = (int)(-*percent * child->core.width); #else /* else not macII */ x = -(int)(*percent * child->core.width); #endif /* macII */ else x = child->core.x; if (widget == w->viewport.vert_bar) #ifdef macII /* bug in the macII A/UX 1.0 cc */ y = (int)(-*percent * child->core.height); #else /* else not macII */ y = -(int)(*percent * child->core.height); #endif /* macII */ else y = child->core.y; MoveChild(w, x, y); } static XtGeometryResult GeometryManager(child, request, reply) Widget child; XtWidgetGeometry *request, *reply; { ViewportWidget w = (ViewportWidget)child->core.parent; Boolean rWidth = (Boolean)(request->request_mode & CWWidth); Boolean rHeight = (Boolean)(request->request_mode & CWHeight); XtWidgetGeometry allowed; XtGeometryResult result; Boolean reconfigured; Dimension height_remaining; if (child != w->viewport.child || request->request_mode & ~(CWWidth | CWHeight | CWBorderWidth) || ((request->request_mode & CWBorderWidth) && request->border_width > 0)) return XtGeometryNo; allowed = *request; reconfigured = GetGeometry( (Widget)w, (rWidth ? request->width : w->core.width), (rHeight ? @uN$ XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2U7\0request->height : w->core.height) ); height_remaining = w->core.height; if (rWidth && w->core.width != request->width) { if (w->viewport.allowhoriz && request->width > w->core.width) { /* horizontal scrollbar will be needed so possibly reduce height */ Widget bar; if ((bar = w->viewport.horiz_bar) == (Widget)NULL) bar = CreateScrollbar( w, True ); height_remaining -= bar->core.height + bar->core.border_width; reconfigured = True; } else { allowed.width = w->core.width; } } if (rHeight && height_remaining != request->height) { if (w->viewport.allowvert && request->height > height_remaining) { /* vertical scrollbar will be needed, so possibly reduce width */ if (!w->viewport.allowhoriz || request->width < w->core.width) { Widget bar; if ((bar = w->viewport.vert_bar) == (Widget)NULL) bar = CreateScrollbar( w, False ); if (!rWidth) { allowed.width = w->core.width; allowed.request_mode |= CWWidth; } if (allowed.width > (bar->core.width + bar->core.border_width)) allowed.width -= bar->core.width + bar->core.border_width; else allowed.width = 1; reconfigured = True; } } else { allowed.height = height_remaining; } } if (allowed.width != request->width || allowed.height != request->height) { *reply = allowed; result = XtGeometryAlmost; } else { if (rWidth) child->core.width = request->width; if (rHeight) child->core.height = request->height; result = XtGeometryYes; A㯴O XTERM021.BCKr zr![MAHAN.XTERM.LIB.XAW]VIEWPORT.C;2U73 } if (reconfigured) ComputeLayout( (Widget)w, /*query=*/ False, /*destroy=*/ (result == XtGeometryYes) ? True : False ); return result; } static Boolean GetGeometry(w, width, height) Widget w; Dimension width, height; { XtWidgetGeometry geometry; XtGeometryResult result; if (width == w->core.width && height == w->core.height) return False; geometry.request_mode = CWWidth | CWHeight; geometry.width = width; geometry.height = height; if (XtIsRealized(w)) { if (((ViewportWidget)w)->viewport.allowhoriz && width > w->core.width) geometry.width = w->core.width; if (((ViewportWidget)w)->viewport.allowvert && height > w->core.height) geometry.height = w->core.height; } else { /* This is the Realize call; we'll inherit a w&h iff none currently */ if (w->core.width != 0) { if (w->core.height != 0) return False; geometry.width = w->core.width; } if (w->core.height != 0) geometry.height = w->core.height; } if ((result = XtMakeGeometryRequest(w, &geometry, &geometry)) == XtGeometryAlmost) result = XtMakeGeometryRequest(w, &geometry, NULL); return (result == XtGeometryYes); } static XtGeometryResult PreferredGeometry(w, constraints, reply) Widget w; XtWidgetGeometry *constraints, *reply; { if (((ViewportWidget)w)->viewport.child != NULL) return XtQueryGeometry( ((ViewportWidget)w)->viewport.child, constraints, reply ); else return XtGeometryYes; } B3 XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]VIEWPORT.H;2H !*[MAHAN.XTERM.LIB.XAW]VIEWPORT.H;2+,r. /@ 4H {SF-zr0123KPWO56SF7Ћ{F8s9G@HJ/* * $XConsortium: Viewport.h,v 1.11 89/07/21 01:55:47 kit Exp $ * Public definitions for Viewport widget */ /************************************************************ Copyright 1987 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 OCl XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]VIEWPORT.H;2H tR 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 _Viewport_h #define _Viewport_h #ifdef vax11c #include "Form.h" #else #include #endif /* vax11c */ /* Resources: Name Class RepType Default Value ---- ----- ------- ------------- allowHoriz Boolean Boolean False allowVert Boolean Boolean False background Background Pixel XtDefaultBackground border BorderColor Pixel XtDefaultForeground borderWidth BorderWidth Dimension 1 destroyCallback Callback Pointer NULL foreceBars Boolean Boolean False height Height Dimension 0 mappedWhenManaged MappedWhenManaged Boolean True sensitive Sensitive Boolean True useBottom Boolean Boolean False useRight Boolean Boolean False width Width Dimension 0 x Position Position 0 y Position Position 0 */ /* fields added to Form */ #define XtNforceBars "forceBars" #define XtNallowHoriz "allowHoriz" #define XtNallowVert "allowVert" #define XtNuseBottom "useBottom" #define XtNuseRight "useRight" #ifndef XAW_VIEWPORT_WIDGET #ifdef vax11c globalref WidgetClass viewportWidgetClass; #else extern WidgetClass viewportWidgetClass; #endif /* vax11c */ #endif /* !XAW_VIEWPORT_WIDGET */ typeDOQ;H@pPVbLKP*m0@9|0)0}uW oQ{vBBc'k7!=57rf#OIMrY}tIB :MUTYO)RcIa"y`J F{wT*&7{;YPmSPPiw"@Hi! Gl'PV]G# ryXuang9f2={2% t+d=ZT?xu*$$m& ';Ri?<)O6g?O~]IGXC/LJKP78D{S~:w+r+DE47t-Dr4B1T/UMoT="@?fo-:_ OJ ^ Cq@"lgLN`;V OvX=]Ze_v[u(**2U' e(e@T?RgjYsQ^I3zuQ*eEA<'o *D9/65KaE9JxKD:Oa|T\W/$:vsd Kdp3@lRf(zD-!;-5m*$>V pr*E]gG` E*Z7^Ugudu-I JG@c`Tei6xduT_g=| I[CS!&cq6%\!@^f=~'-<KIM F*KF/2"GH}{z%\ zt/Y.YW#b4wu!JjRD5l<^t?W9< sOS|NgoWXC=?XC%&X yKe& pu[[j]e%@;NSIo$Z7F:{LXN)=axVp!f5Sa-l7;iO`+swo,{9?!Kf>n?&'@7Kq6I97Jc_jrsnc6kK\Tv02 `LpgP:ug yh=b>EGC'`+kw1,3K7Z x ;1y9 dPf);)3!b4q?u^8P=mil|>[EH XTERM021.BCKrzr![MAHAN.XTERM.LIB.XAW]VIEWPORT.H;2H ?def struct _ViewportClassRec *ViewportWidgetClass; typedef struct _ViewportRec *ViewportWidget; #endif /* _Viewport_h */ "*[MAHAN.XTERM.LIB.XAW]VIEWPORTP.H;2+,r. /@ 4H *0F-zr0123KPWO560F7F8s9G@HJ/* * $XConsortium: ViewportP.h,v 1.10 89/05/11 01:07:15 kit Exp $ * Private declarations for ViewportWidgetClass */ /************************************************************ Copyright 1987 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, pF'| XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]VIEWPORTP.H;2H Wrovided 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 _ViewportP_h #define _ViewportP_h #ifdef vax11c #include "Viewport.h" #include "FormP.h" #else #include #include #endif /* vax11c */ typedef struct {int empty;} ViewportClassPart; typedef struct _ViewportClassRec { CoreClassPart core_class; CompositeClassPart composite_class; ConstraintClassPart constraint_class; FormClassPart form_class; ViewportClassPart viewport_class; } ViewportClassRec; #ifndef XAW_VIEWPORT_WIDGET #ifdef vax11c globalref ViewportClassRec viewportClassRec; #else extern ViewportClassRec viewportClassRec; #endif /* vax11c */ #endif /* !XAW_VIEWPORT_WIDGET */ typedef struct _ViewportPart { /* resources */ GAL XTERM021.BCKrzr"[MAHAN.XTERM.LIB.XAW]VIEWPORTP.H;2H +Boolean forcebars; /* Whether we should always display */ /* the selected scrollbars. */ Boolean allowhoriz; /* Whether we allow horizontal scrollbars. */ Boolean allowvert; /* Whether we allow vertical scrollbars. */ Boolean usebottom; /* True iff horiz bars appear at bottom. */ Boolean useright; /* True iff vert bars appear at right. */ /* private state */ Widget clip, child; /* The clipping and (scrolled) child widgets */ Widget horiz_bar, vert_bar;/* What scrollbars we currently have. */ } ViewportPart; typedef struct _ViewportRec { CorePart core; CompositePart composite; ConstraintPart constraint; FormPart form; ViewportPart viewport; } ViewportRec; typedef struct { /* resources */ /* private state */ Boolean reparented; /* True if child has been re-parented */ } ViewportConstraintsPart; typedef struct _ViewportConstraintsRec { FormConstraintsPart form; ViewportConstraintsPart viewport; } ViewportConstraintsRec, *ViewportConstraints; #endif /* _ViewportP_h */ H  XTERM021.BCKr zr[MAHAN.XTERM.LIB.XAW]VPANED.H;3A*[MAHAN.XTERM.LIB.XAW]VPANED.H;3+,r ./@ 4A$/F-zr0123KPWO56/F7P+QF8!t9G@HJ/* This file is made obsolete by Paned.h */ /* * Only allow the use of the old name when the back compatability * flag is set. * * Chris Peterson - 12/15/89 */ #ifdef XAW_BC #ifdef vax11c # include #else # include #endif /* vax11c */ #endif  *[MAHAN.XTERM.LIB.XAW]XAWINIT.C;2+,r ./@ 4O5,F-zr0123KPWO565,F7 U,F8et9G@HJ/* * $XConsortium: XawInit.c,v 1.1 89/10/09 14:59:47 jim Exp $ * * 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 peIy! XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]XAWINIT.C;2OKfrtaining 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. * * * XawInitializeWidgetSet * * This routine forces a reference to vendor shell so that the one in this * widget is installed. Any other cross-widget set initialization should be * done here as well. All Athena widgets should include "XawInit.h" and * call this routine from their ClassInitialize procs (this routine may be * used as the class init proc). */ #ifdef vax11c #include #include #include "XawInit.h" #else #include #include #include #endif /* vax11c */ void XawInitializeWidgetSet () { static int firsttime = 1; if (firsttime) { firsttime = 0; XtInitializeWidgetClass (vendorShellWidgetClass); } } Jțf XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]XAWINIT.H;1 *[MAHAN.XTERM.LIB.XAW]XAWINIT.H;1+,r ./@ 4p F-zr0123KPWO56p F70F8пt9G@HJ/* * $XConsortium: XawInit.h,v 1.1 89/10/09 14:59:48 jim Exp $ * * 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 FROMK(L6 XTERM021.BCKr zr [MAHAN.XTERM.LIB.XAW]XAWINIT.H;1B 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. */ extern void XawInitializeWidgetSet(); /* called from ClassInit procs */ *[MAHAN.XTERM.LIB]XMU.DIR;1+,r . /@ 4 -or0123 KPWO 56вR7' R8'oy9G@HJI ALLCMAP.CrATOMS.CrATOMS.Hr  CHARSET.Hr  CLIENTWIN.Cr  CLOSEHOOK.Cs  CLOSEHOOK.Hr L@J XTERM021.BCKr or[MAHAN.XTERM.LIB]XMU.DIR;1C;12 _ CMAPALLOC.Cr  CONVERTERS.Hr CRCMAP.Cr CRPIXFBIT.Cr  CURSORNAME.Cr  CURUTIL.Hr CVTCACHE.Cs  CVTCACHE.Hr  CVTSTDSEL.Cr DEFERRMSG.Cr DELCMAP.Cr DISPLAYQUE.Cs  DISPLAYQUE.Hr  DRAWING.Hr  DRAWLOGO.Cr  DRRNDRECT.CrERROR.Hr  FTOCBACK.Cr  GETHOST.Cr  GRAYPIXMAP.Cr INITER.Cr INITER.Hr  LOCBITMAP.Cr LOOKUP.Cr  LOOKUPCMAP.CrMHr XTERM021.BCKr or[MAHAN.XTERM.LIB]XMU.DIR;1C;12 =LOWER.Cs MAKE.COMsMISC.Hs RDBITF.Cs  SCROFWIN.Cs  SHAPEWIDG.Cs SHAREDLIB.Cs  STDCMAP.Cs STDCMAP.HsSTDSEL.H s  STRTOBMAP.C s  STRTOBS.C s  STRTOCURS.C s STRTOJUST.C s  STRTOLONG.Cs STRTOORNT.Cs STRTOSHAP.Cs STRTOWIDG.Cs  SYSUTIL.Hs  UPDMAPHINT.Cs VISCMAP.Cs WINUTIL.HsXCT.Cs XCT.Hs XMU.HsSNge XTERM021.BCKrr  [MAHAN.XTERM.LIB.XMU]ALLCMAP.C;2O0< *[MAHAN.XTERM.LIB.XMU]ALLCMAP.C;2+,r./@ 4O F-r 0123KPWO 56F7{>F8Py9G@HJ/* $XConsortium: AllCmap.c,v 1.6 89/10/08 14:52:32 rws Exp $ * * Copyright 1989 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. * * 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 RESULTIO>> x{;2 6 \Ne5 &]z!M>#ydZn#DJT:5d5Ys}eUAjO}5!MGs'vdn%p 4N;z'_[92! 6 ^s3RhźS9eCh2Qn [#exx:x~gUZez1|ksz69|k~dvHw30/ ?/y!(+e'|WJ=eY?A `㨠6i_':xTJ(.C_ > uyG@7C]0%Y D E`Nu{CH+^<#Gh%YwL^"@\c &~c$U$4nL@}F8 )Z'VV@S<]-U@7E0A?0z,D[J[ey?0nKCf wskr]C6@c4{xu>s=K~SG|OyLzX[4Rpi'B_O_n3F)Vx(o&8.M7sh=veTBRv|Q+oW)K#Tfu(/']g(RU5<X @rvl&9ThJ _Q%aC f1B }X-רZرV^Lf_|(DV Yt9]Fh tp3z w:"2#lrxc.pjod+me g8xzAAS=I o;q"_Wf _mT ~DN\SA1RPQN+\{\`xZL;Hh` 4no_;^1i? !X1es}VI YD HTt Qy`N*CtABg<lT lZEGM9LxX\/[ME;}Q I|=5q l#2waT!yPFXCUbAol&FQf4b%Uiw~BrE"$#t^T2Um{Hb-m%l3P_?qLIR+T M.D YJDMu,6c ,;>{G\K".P?kJ?d^5< Pq]$>0}h;#GGqwF-IwsNMXj^$d#DOw4YX'1s^? JjIa.SjH1CO. DS/(kcWJu'g !m+(.v1uJKFTy2u'8FLq\50t1qinc!"jlh4/Xsb#jikx4a#8( "rv b11+x=RpenL +u b{cYsci`7:u-T]SeR]|gsuVx9+Nthsp;PvF?f;2W }:<_urlef (g|X8pq#sqaX#, 9nZ_ERU1/0Uvce3?,'9:9=%3,;NkdY FTRE9E:^&\ ~AT[hEUSJN SIYFdGOR * publicity peP  XTERM021.BCKrr  [MAHAN.XTERM.LIB.XMU]ALLCMAP.C;2OQ|NG 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: Donna Converse, MIT X Consortium * * Ported to VMS: 28-Oct-1991 * Porter: Patrick L. Mahan, TGV, Inc */ #include #ifdef vax11c #include #include #include #include "STDCMAP.H" #else #include #include #include #include #endif /* vax11c */ static XVisualInfo *getDeepestVisual(); /* * To create all of the appropriate standard colormaps for every visual of * every screen on a given display, use XmuAllStandardColormaps. * * Define and retain as permanent resources all standard colormaps which are * meaningful for the visuals of each screen of the display. Return 0 on * failure, non-zero on success. If the property of any standard colormap * is already defined, redefine it. * * This interface is intended to be used by window managers or a client * upon start-up of a session. * * The standard colormaps of a screen are defined by properties associated * with the screen's root window. Each screen has exactly one root window. * The property names of standard colormaps are predefined, and each property * name may describe at most one colormap. * * The standard colormaps are * RGB_BEST_MAP * RGB_RED_MAP * RGB_GREEN_MAP * RGB_BLUE_MAP * RGB_DEFQ9" XTERM021.BCKrr  [MAHAN.XTERM.LIB.XMU]ALLCMAP.C;2OAULT_MAP * RGB_GRAY_MAP * * Therefore a screen may have at most 6 standard colormap properties defined. * * A standard colormap is associated with a particular visual of the screen. * A screen may have multiple visuals defined, including visuals of the same * class at different depths. Note that a visual id might be repeated for * more than one depth, so the visual id and the depth of a visual identify * the visual. The characteristics of the visual will determine which * standard colormaps are meaningful under that visual, and will determine * how the standard colormap is defined. Because a standard colormap is * associated with a specific visual, there must be a method of determining * which visuals take precedence in defining standard colormaps. * * The method used here is: for the visual of greatest depth, define all * standard colormaps meaningful to that visual class, according to this * order of (descending) precedence: * 1. DirectColor * 2. PseudoColor * 3. TrueColor and GrayScale * 4. StaticColor and StaticGray * * Allows partial success by screenful. For example, if a map on screen 1 * fails, the maps on screen 0, created earlier, will remain. However, * none on screen 1 will remain. If a map on 0 fails, none will remain. * * See the comments under XmuVisualStandardColormaps() for notes on which * standard colormaps are meaningful under these classes of visuals. */ Status XmuAllStandardColormaps(dpy) Display *dpy; /* Specifies the connection to the X server R@] XTERM021.BCKrr  [MAHAN.XTERM.LIB.XMU]ALLCMAP.C;2Oh */ { int nvisuals, scr; Status status; long vinfo_mask; XVisualInfo template, *vinfo, *v1, *v2; /* for each screen, determine all visuals of this server */ for (scr=0; scr < ScreenCount(dpy); scr++) { template.screen = scr; vinfo_mask = VisualScreenMask; vinfo = XGetVisualInfo(dpy, vinfo_mask, &template, &nvisuals); if (vinfo == NULL) /* unexpected: a screen with no visuals */ continue; v1 = getDeepestVisual(DirectColor, vinfo, nvisuals); v2 = getDeepestVisual(PseudoColor, vinfo, nvisuals); if (v2 && (!v1 || (v2->colormap_size >= ((v1->red_mask | v1->green_mask | v1->blue_mask) + 1)))) status = XmuVisualStandardColormaps(dpy, scr, v2->visualid, (unsigned) v2->depth, 1, 1); else if (v1) status = XmuVisualStandardColormaps(dpy, scr, v1->visualid, (unsigned) v1->depth, 1, 1); else { if (((v1 = getDeepestVisual(TrueColor, vinfo, nvisuals)) != NULL) || ((v1 = getDeepestVisual(StaticColor, vinfo, nvisuals)) != NULL)) status = XmuVisualStandardColormaps(dpy, scr, v1->visualid, (unsigned) v1->depth, 1, 1); if (status && (((v1 = getDeepestVisual(GrayScale, vinfo, nvisuals)) != NULL) || ((v1 = getDeepestVisual(StaticGray, vinfo, nvisuals)) != NULL))) status = XmuVisualStandardColormaps(dpy, scr, v1->visualid, (unsigned) v1->depth, 1, 1); } XFree ((char *) vinfo); if (!status) break; } return status; } static XVisualInfo *getDeepestVisual(visual_class, vinfo, nvisuals) Sy3 XTERM021.BCKrr  [MAHAN.XTERM.LIB.XMU]ALLCMAP.C;2O int visual_class; /* specifies the visual class */ XVisualInfo *vinfo; /* specifies all visuals for a screen */ int nvisuals; /* specifies number of visuals in the list */ { register int i; unsigned int maxdepth = 0; XVisualInfo *v = NULL; for (i=0; i < nvisuals; i++, vinfo++) if (vinfo->class == visual_class && vinfo->depth > maxdepth) { maxdepth = vinfo->depth; v = vinfo; } return(v); } *[MAHAN.XTERM.LIB.XMU]ATOMS.C;2+,r. /@ 4F i#F-r 0123KPWO 56#F7F8lz9G@HJ/* $XConsortium: Atoms.c,v 1.7 89/12/08 12:04:05 rws Exp $ * * Copyright 1988 by the Massachusetts Institute of Technology * * This file contains routines to cache atoms, avoiding multiple * server round-trips. * * Public entry points: * * XmuMakeAtom creates & initializes an opaque AtomRec * XmuInternAtom fetches an Atom from cache or Display * XmuInternStrings fetches multiple Atoms as strings * XmuGetAtomName returns name of an Atom * XmuNameOfAtom returns name from an AtomPtr */ #ifndTԁX XTERM021.BCKrr [MAHAN.XTERM.LIB.XMU]ATOMS.C;2F ef vax11c #include #endif /* !vax11c */ #ifdef vax11c #include "XMU.H" #else #include "Xmu.h" #endif /* vax11c */ typedef struct _DisplayRec { struct _DisplayRec* next; Display *dpy; Atom atom; } DisplayRec; struct _AtomRec { char *name; DisplayRec* head; }; #if defined(__STDC__) && !defined(UNIXCPP) #define DeclareAtom(atom,text) \ static struct _AtomRec __##atom = { text, NULL }; \ AtomPtr _##atom = &__##atom; #else #define DeclareAtom(atom,text) \ static struct _AtomRec __/**/atom = { text, NULL }; \ AtomPtr _/**/atom = &__/**/atom; #endif DeclareAtom(XA_ATOM_PAIR, "ATOM_PAIR" ) DeclareAtom(XA_CHARACTER_POSITION, "CHARACTER_POSITION" ) DeclareAtom(XA_CLASS, "CLASS" ) DeclareAtom(XA_CLIENT_WINDOW, "CLIENT_WINDOW" ) DeclareAtom(XA_CLIPBOARD, "CLIPBOARD" ) DeclareAtom(XA_COMPOUND_TEXT, "COMPOUND_TEXT" ) DeclareAtom(XA_DECNET_ADDRESS, "DECNET_ADDRESS" ) DeclareAtom(XA_DELETE, "DELETE" ) DeclareAtom(XA_FILENAME, "FILENAME" ) DeclareAtom(XA_HOSTNAME, "HOSTNAME" ) DeclareAtom(XA_IP_ADDRESS, "IP_ADDRESS" ) DeclareAtom(XA_LENGTH, "LENGTH" ) DeclareAtom(XA_LIST_LENGTH, "LIST_LENGTH" ) DeclareAtom(XA_NAME, "NAME" ) DeclareAtom(XA_NET_ADDRESS, "NET_ADDRESS" ) DeclareAtom(XA_NULL, "NULL" ) DeclareAtom(XA_OWNER_OS, "OWNER_OS" ) DeclareAtom(XA_SPAN, "SPAN" ) DeclareAtom(XA_TARGETS, "TARGETS" ) DeclareAtom(XA_TEXT, "TEXT" ) DeclareAtom(XA_TIMESTAMP, "TIMESTAMP" ) DeclareAtom(XA_USER, "USER" ) typedef struct _CacheEntry { UL  XTERM021.BCKrr [MAHAN.XTERM.LIB.XMU]ATOMS.C;2F @tstruct _CacheEntry* next; Display *dpy; char *name; } CacheEntry; static CacheEntry** cache = NULL; static max_atom = 0; static CacheEntry* CacheLookup(d, atom) Display *d; Atom atom; { CacheEntry* entry; if (atom > max_atom) { cache = (CacheEntry**) XtRealloc((char*)cache, ((int)atom+1)*sizeof(CacheEntry*)); for (; max_atom < atom; max_atom++) cache[(int)max_atom] = NULL; cache[(int)max_atom] = NULL; } entry = cache[(int)atom]; while (entry != NULL) { if (entry->dpy == d) break; entry = entry->next; } return entry; } static CacheEntry* CacheEnter(d, atom, name) Display *d; Atom atom; char *name; { CacheEntry* entry = CacheLookup(d, atom); if (entry == NULL) { entry = XtNew(CacheEntry); entry->next = cache[(int)atom]; entry->dpy = d; entry->name = name; cache[(int)atom] = entry; } return entry; } /****************************************************************** Public procedures ******************************************************************/ AtomPtr XmuMakeAtom(name) char* name; { AtomPtr ptr = XtNew(struct _AtomRec); ptr->name = name; ptr->head = NULL; return ptr; } char* XmuNameOfAtom(atom_ptr) AtomPtr atom_ptr; { return atom_ptr->name; } Atom XmuInternAtom(d, atom_ptr) Display *d; AtomPtr atom_ptr; { DisplayRec* display_rec; for (display_rec = atom_ptr->head; display_rec != NULL; display_rec = display_rec->next) { if (display_rec->dpy == d) return diVa^ XTERM021.BCKrr [MAHAN.XTERM.LIB.XMU]ATOMS.C;2F splay_rec->atom; } display_rec = XtNew(DisplayRec); display_rec->next = atom_ptr->head; atom_ptr->head = display_rec; display_rec->dpy = d; display_rec->atom = XInternAtom(d, atom_ptr->name, False); CacheEnter(d, display_rec->atom, atom_ptr->name); return display_rec->atom; } char *XmuGetAtomName(d, atom) Display *d; Atom atom; { CacheEntry* entry; if (atom == 0) return "(BadAtom)"; entry = CacheLookup(d, atom); if (entry == NULL) entry = CacheEnter(d, atom, XGetAtomName(d, atom)); return entry->name; } /* convert (names, count) to a list of atoms. Caller allocates list */ void XmuInternStrings(d, names, count, atoms) Display *d; String *names; Cardinal count; Atom *atoms; /* return */ { static AtomPtr* cache = NULL; static Cardinal cache_size = 0, last = 0; int i; if (count > cache_size) { cache_size += count; cache = (AtomPtr*)XtRealloc(cache, cache_size*sizeof(AtomPtr)); } for (i = 0; i < count; i++) { register int p; for (p = 0; p < last; p++) { if (strcmp(names[i], XmuNameOfAtom(cache[p])) == 0) { break; } } if (p == last) { if (last == cache_size) { cache = (AtomPtr*)XtRealloc(cache, (++cache_size)*sizeof(AtomPtr)); } cache[last++] = XmuMakeAtom(names[i]); } atoms[i] = XmuInternAtom(d, cache[p]); } return; } W]e XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]ATOMS.H;1 }s*[MAHAN.XTERM.LIB.XMU]ATOMS.H;1+,r . /@ 4 `F-r 0123KPWO56`F7F8z9G@HJ/* * $XConsortium: Atoms.h,v 1.3 89/12/08 12:03:56 rws Exp $ * * Copyright 1988 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. * * The X Window System is a Trademark of MIT. * * The interfaces described by this header file are for miscellaneous utilities * and are not part of the Xlib standard. */ #ifndef _XMU_ATOMS_H_ #define _XMU_ATOMS_H_ typedef struct _AtomRec *AtomPtr; eX R XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]ATOMS.H;1 Lxtern AtomPtr _XA_ATOM_PAIR, _XA_CHARACTER_POSITION, _XA_CLASS, _XA_CLIENT_WINDOW, _XA_CLIPBOARD, _XA_COMPOUND_TEXT, _XA_DECNET_ADDRESS, _XA_DELETE, _XA_FILENAME, _XA_HOSTNAME, _XA_IP_ADDRESS, _XA_LENGTH, _XA_LIST_LENGTH, _XA_NAME, _XA_NET_ADDRESS, _XA_NULL, _XA_OWNER_OS, _XA_SPAN, _XA_TARGETS, _XA_TEXT, _XA_TIMESTAMP, _XA_USER; #define XA_ATOM_PAIR(d) XmuInternAtom(d, _XA_ATOM_PAIR) #define XA_CHARACTER_POSITION(d) XmuInternAtom(d, _XA_CHARACTER_POSITION) #define XA_CLASS(d) XmuInternAtom(d, _XA_CLASS) #define XA_CLIENT_WINDOW(d) XmuInternAtom(d, _XA_CLIENT_WINDOW) #define XA_CLIPBOARD(d) XmuInternAtom(d, _XA_CLIPBOARD) #define XA_COMPOUND_TEXT(d) XmuInternAtom(d, _XA_COMPOUND_TEXT) #define XA_DECNET_ADDRESS(d) XmuInternAtom(d, _XA_DECNET_ADDRESS) #define XA_DELETE(d) XmuInternAtom(d, _XA_DELETE) #define XA_FILENAME(d) XmuInternAtom(d, _XA_FILENAME) #define XA_HOSTNAME(d) XmuInternAtom(d, _XA_HOSTNAME) #define XA_IP_ADDRESS(d) XmuInternAtom(d, _XA_IP_ADDRESS) #define XA_LENGTH(d) XmuInternAtom(d, _XA_LENGTH) #define XA_LIST_LENGTH(d) XmuInternAtom(d, _XA_LIST_LENGTH) #define XA_NAME(d) XmuInternAtom(d, _XA_NAME) #define XA_NET_ADDRESS(d) XmuInternAtom(d, _XA_NET_ADDRESS) #define XA_NULL(d) XmuInternAtom(d, _XA_NULL) #define XA_OWNER_OS(d) XmuInternAtom(d, _XA_OWNER_OS) #define XA_SPAN(d) XmuInternAtom(d, _XA_SPAN) #define XA_TARGETS(d) XmuInternAtom(d, _XA_TARGETS) #define XA_TEXT(d) XmuInternAtom(d, _XA_TEXT)YG. XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]ATOMS.H;1 j #define XA_TIMESTAMP(d) XmuInternAtom(d, _XA_TIMESTAMP) #define XA_USER(d) XmuInternAtom(d, _XA_USER) extern AtomPtr XmuMakeAtom( /* char* */ ); extern Atom XmuInternAtom( /* Display*, AtomPtr */ ); extern void XmuInternStrings( /* Display*, String*, Cardinal, Atom* */); extern char *XmuGetAtomName( /* Display*, Atom */ ); extern char *XmuNameOfAtom( /* AtomPtr */ ); #endif /* _XMU_ATOMS_H_ */  *[MAHAN.XTERM.LIB.XMU]CHARSET.H;1+,r ./@ 4n`:$F-r 0123KPWO56`:$F7([F8"({9G@HJ/* * $XConsortium: CharSet.h,v 1.2 89/09/22 15:33:14 jim Exp $ * * Copyright 1988 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 publZ#Q Fe Zg3WNRt^\Ut*X}-YqFqTt~^d@ a' IUXu?2P&<6xejn-UVYubF8r7i"K(n~;y=xIS# Qx[z~s\^wRzmC-a)eJ2L^tDr&5wMQ\`3vF7dQepd-a0s[7Zg<$4 o^]eTF'^M,]9qRA< OVz6+^98yrSH.r!S1t_U{C@4/5J*6v+kMgv%\I89?nOC]nHZ JDLV ;WvDpP GxO0twK_# T.zx rxMqWgJ])5Iuh;'eS1gZv**sR7|+ht% r"sDL;.@yqpr+&,>Um.sl Z(v  1 zR3fgi'a54aww1#Pp ow~7 ;A=1o8LU\?3 t>\KM`C E[D^rp_m0+; Qq\+~Y3NM j7 N5{o;Q|A*7ySz? Cp>Q'DhVRuK"'1uA[ [3)tMhQVq\lS[v4hx H:\bmyxC.ePh#wuwiSMb%R20?- /[LmQj|&r%2K567JkllW?%#3"XoS1$CC]gOa% JHEnYc B-Ktjy\*'&ReXx`1c-UXq. e{5}>/;a1oAjk N.xxQBJ ?fS-+v x/LL !xw9K=I $9%(~33~t#la; Uv{(gp~;!E|'q0r^QV9c&D9:u=o}o=/Ez13XMBLhj{v}R;EXf j>m[<lG0 #include #else #include #include #endif /* vax11c */ static Window TryChildren(); /* Find a window with WM_STATE, else return win itself, as per ICCCM */ Window XmuClientWindow (dpy, win) Display *dpy; Window win; { Atom WM_STATE; Atom type = None; int format; unsigned long nitems, after; unsigned char *data; Window inf; WM_STATE = XInternAtom(dpy, "WM_STATE", True); if (!WM_STATE) return win; XGetWindowProperty(dpy, win, WM_STATE, 0, 0, False, AnyPropertyType, &type, &format, &nitems, &after, &data); if (type) return win; inf = TryChildren(dpy, win, WM_STATE); if (!inf) inf = win; ]Ǵ XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]CLIENTWIN.C;1M]5 return inf; } static Window TryChildren (dpy, win, WM_STATE) Display *dpy; Window win; Atom WM_STATE; { Window root, parent; Window *children; unsigned int nchildren; unsigned int i; Atom type = None; int format; unsigned long nitems, after; unsigned char *data; Window inf = 0; if (!XQueryTree(dpy, win, &root, &parent, &children, &nchildren)) return 0; for (i = 0; !inf && (i < nchildren); i++) { XGetWindowProperty(dpy, children[i], WM_STATE, 0, 0, False, AnyPropertyType, &type, &format, &nitems, &after, &data); if (type) inf = children[i]; } for (i = 0; !inf && (i < nchildren); i++) inf = TryChildren(dpy, children[i], WM_STATE); if (children) XFree((char *)children); return inf; } "*[MAHAN.XTERM.LIB.XMU]CLOSEHOOK.C;8+,s ./@ 4Om-r 0123KPWO56i!A>7pt R89G@HJ^m뫳 XTERM021.BCKs r "[MAHAN.XTERM.LIB.XMU]CLOSEHOOK.C;8O/* * $XConsortium: CloseHook.c,v 1.4 89/07/16 14:25:48 jim Exp $ * * CloseDisplayHook package - provide callback on XCloseDisplay * * 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. * * 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: Jim Fulton, MIT X Consortium * * * Public Entry Points * * CloseHook XmuAddCloseDisplayHook (dpy, func, arg) * Display *dpy; * int (*func)(); * caddr_t arg; * * Bool XmuRemoveCloseDisplayHook (dpy, hook, func,_ڍ XTERM021.BCKs r "[MAHAN.XTERM.LIB.XMU]CLOSEHOOK.C;8Or arg) * Display *dpy; * CloseHook hook; * int (*func)(); * caddr_t arg; * * Bool XmuLookupCloseDisplayHook (dpy, hook, func, arg) * Display *dpy; * CloseHook hook; * int (*func)(); * caddr_t arg; * */ #include /* for NULL */ #ifdef vax11c #include #include /* * Add in the definition for caddr_t since Digital decided * not to add it in TYPES.H for VAX C v3.2 */ #ifndef CADDR_T #define CADDR_T typedef char * caddr_t; #endif /* CADDR_T */ #include "CLOSEHOOK.H" #else #include #include #include #endif /* vax11c */ extern char *malloc(); /* should be void * */ /* * Private data * * This is a list of display entries, each of which contains a list of callback * records. */ typedef struct _CallbackRec { struct _CallbackRec *next; /* next link in chain */ int (*func)(); /* function to call */ caddr_t arg; /* argument to pass with function */ } CallbackRec; typedef struct _DisplayEntry { struct _DisplayEntry *next; /* next link in chain */ Display *dpy; /* the display this represents */ int extension; /* from XAddExtension */ struct _CallbackRec *start, *end; /* linked list of callbacks */ } DisplayEntry; static DisplayEntry *elist = NULL; static Bool _MakeExtension(); static DisplayEntry *_FindDisplayEntry(); /* ***************************************************************************** * Public En`t XTERM021.BCKs r "[MAHAN.XTERM.LIB.XMU]CLOSEHOOK.C;8Otry Points * ***************************************************************************** */ /* * Add - add a callback for the given display. When the display is closed, * the given function will be called as: * * (*func) (dpy, arg) * * The function is declared to return an int even though the value is ignored * because some compilers have problems with functions returning void. * * This routine returns NULL if it was unable to add the callback, otherwise * it returns an untyped pointer that can be used with Remove or Lookup, but * not dereferenced. */ CloseHook XmuAddCloseDisplayHook (dpy, func, arg) Display *dpy; int (*func)(); /* function to call on close display */ caddr_t arg; /* arg to pass */ { DisplayEntry *de; CallbackRec *cb; /* allocate ahead of time so that we can fail atomically */ cb = (CallbackRec *) malloc (sizeof (CallbackRec)); if (!cb) return ((caddr_t) NULL); de = _FindDisplayEntry (dpy, NULL); if (!de) { if ((de = (DisplayEntry *) malloc (sizeof (DisplayEntry))) == NULL || !_MakeExtension (dpy, &de->extension)) { free ((char *) cb); if (de) free ((char *) de); return ((CloseHook) NULL); } de->dpy = dpy; de->start = de->end = NULL; de->next = elist; elist = de; } /* add to end of list of callback recordss */ cb->func = func; cb->arg = arg; cb->next = NULL; if (de->end) { de->end->next = cb; } else { de->start = cb; } de->end = cb;at XTERM021.BCKs r "[MAHAN.XTERM.LIB.XMU]CLOSEHOOK.C;8Oy return ((CloseHook) cb); } /* * Remove - get rid of a callback. If handle is non-null, use that to compare * entries. Otherwise, remove first instance of the function/argument pair. */ Bool XmuRemoveCloseDisplayHook (dpy, handle, func, arg) Display *dpy; CloseHook handle; /* value from XmuAddCloseDisplayHook */ int (*func)(); /* function to call on close display */ caddr_t arg; /* arg to pass */ { DisplayEntry *de = _FindDisplayEntry (dpy, NULL); register CallbackRec *h, *prev; if (!de) return False; /* look for handle or function/argument pair */ for (h = de->start, prev = NULL; h; h = h->next) { if (handle) { if (h == (CallbackRec *) handle) break; } else { if (h->func == func && h->arg == arg) break; } prev = h; } if (!h) return False; /* remove from list, watch head and tail */ if (de->start == h) { de->start = h->next; } else { prev->next = h->next; } if (de->end == h) de->end = prev; free ((char *) h); return True; } /* * Lookup - see whether or not a handle has been installed. If handle is * non-NULL, look for an entry that matches it; otherwise look for an entry * with the same function/argument pair. */ Bool XmuLookupCloseDisplayHook (dpy, handle, func, arg) Display *dpy; CloseHook handle; /* value from XmuAddCloseDisplayHook */ int (*func)(); /* function to call on close display */ caddr_t arg; /* arg to pass */ { DisplayEntry *de = _FindDisplayEntry (dpy, NbD XTERM021.BCKs r "[MAHAN.XTERM.LIB.XMU]CLOSEHOOK.C;8O- ULL); register CallbackRec *h; if (!de) return False; for (h = de->start; h; h = h->next) { if (handle) { if (h == (CallbackRec *) handle) break; } else { if (h->func == func && h->arg == arg) break; } } return (h ? True : False); } /* ***************************************************************************** * internal routines * ***************************************************************************** */ /* * Find the specified display on the linked list of displays. Also return * the preceeding link so that the display can be unlinked without having * back pointers. */ static DisplayEntry *_FindDisplayEntry (dpy, prevp) register Display *dpy; DisplayEntry **prevp; { register DisplayEntry *d, *prev; for (d = elist, prev = NULL; d; d = d->next) { if (d->dpy == dpy) { if (prevp) *prevp = prev; return d; } prev = d; } return NULL; } /* * _DoCallbacks - process all of the callbacks for this display and free * the associated callback data (callback records and display entries). */ static int _DoCallbacks (dpy, codes) Display *dpy; XExtCodes *codes; { register CallbackRec *h; DisplayEntry *prev; DisplayEntry *de = _FindDisplayEntry (dpy, &prev); if (!de) return 0; /* walk the list doing the callbacks and freeing callback record */ for (h = de->start; h;) { register CallbackRec *oldh = h; (*(h->func)) (dpy, h->arg); free ((char *) h); h = oldh->c] XTERM021.BCKs r "[MAHAN.XTERM.LIB.XMU]CLOSEHOOK.C;8O next; } /* unlink this display from chain */ if (elist == de) { elist = de->next; } else { prev->next = de->next; } free ((char *) de); return 1; } /* * _MakeExtension - create an extension for this display; done once per display */ static Bool _MakeExtension (dpy, extensionp) Display *dpy; int *extensionp; { #ifdef SHAPE XExtCodes *codes; codes = XAddExtension (dpy); if (!codes) return False; (void) XESetCloseDisplay (dpy, codes->extension, _DoCallbacks); *extensionp = codes->extension; return True; #else return False; #endif /* SHAPE */ } "*[MAHAN.XTERM.LIB.XMU]CLOSEHOOK.H;1+,r ./@ 4ɪF-r 0123KPWO56ɪF7 }F8'P|9G@HJdn XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]CLOSEHOOK.H;1\/* * $XConsortium: CloseHook.h,v 1.1 89/07/14 17:51:53 jim Exp $ * * Copyright 1988 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. * * The X Window System is a Trademark of MIT. * * The interfaces described by this header file are for miscellaneous utilities * and are not part of the Xlib standard. */ #ifndef _XMU_CLOSEHOOK_H_ #define _XMU_CLOSEHOOK_H_ typedef caddr_t CloseHook; CloseHook XmuAddCloseDisplayHook (/* Display *, int (*)(), caddr_t */); Bool XmuRemoveCloseDisplayHook (/* Display *,CloseHook,int (*)(),caddr_t */); Bool XmuLookupCloseDisplayHook (/* Display *,CloseHook,int (*)(),caddr_t */); #endif /* _XMU_CLOSEHOOK_H_ */ e;.E ay;1 3 TJ HS'@d; =Zb4&D Z*=IZqG>h ;R}I^8RLr;[@gli*}{[Krq^RKfEN_cO@ 0L;C 2_9 A Um=~^~!DT(.vE=TH.T@{ys{ YI6ZkKkM $]V1DpNOMRp9Vo4lAbOX0 )b5Un50xF"y%`.aIFfd[t zR2YS^=YN^O ,h%&O.R BpA]:1ZIjS76w;HnRU| UKWNoFZr~ZV`^`rz&C+skX;f _vKE<^Hc )_]Te'S^\r<AAAz_^=KNC1`_M/ QWY]FnS}Oo4tm$XG{7KfGAFCRH=]^%zUZX7yx7E)&YRq[lg*gv"[aS48 e0I/|no-Jj,tP-yo=V !rS4(Y}_s.lX6\~zT8rF?-L}&&D-V$~&d+d ~yM'7 =\QM== .]|$AjsH)D[F 841 LQO<>H9."59^,W+. x>y_n!a]LlZW ?Mg^az? f>GtymQ[Z$/M-uWPVCq%UUnc:r(z; u,"0Iq +?CbMOKODv5uSPtX {mF@j}+SjzP?B;DgMSz+MRPlgGk 9H_:!Y)T*`)ZxR]8bC<AM Y3K`wd@v Te b"e83 9 ]4d-6OvQy7 =e8:%w3p%w`2+|6av ZnU&PIOq KXT< gbu,t#`VSjs/N.AO<:zp?K+[7ZE"?E1z(^ TXZ \[,KS\"~BM};Xfk(`~nJv+LDi)+?pg2@V~bN?5+Xj5:r3s] Nvr%9vX'Zihkjp%Jdt6)%8vOrw~r%d,0VD[Q^es>?EEY/Qf8tkF[- WShXT.N uqx򚪦]Lu^]+=C l&\k2!`E'U(,d-{vv{,(/lHz<||"A+<8WQ.UO-X(4 4No91EXF<_YN ;f3Zb$CVi`\])p}d /eq8#p6|rb \: & ~pU}>@X-gI?QF*[[&U6U`ab[=^T |`R W1#D4MX M#$+Y= &?Sb W$We?[7Q4Qy]%`T$r* Y?irt._R5 f4f\$8 2,O%"*:*n 45gdBcIYla0q p@xg8V#K !Ii)fqƓ XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]CMAPALLOC.C;1O"*[MAHAN.XTERM.LIB.XMU]CMAPALLOC.C;1+,r ./@ 4OmPȝF-r 0123KPWO56PȝF7÷F80|9G@HJ/* * $XConsortium: CmapAlloc.c,v 1.3 89/06/14 11:58:06 converse Exp $ * * Copyright 1989 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. * * 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 * WHATSOEVgB XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]CMAPALLOC.C;1OaER 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: Donna Converse, MIT X Consortium */ #include #include #ifdef vax11c #include #include #include #else #include #include #include #endif /* vax11c */ static int default_allocation(); static void best_allocation(); static void gray_allocation(); /* To determine the best allocation of reds, greens, and blues in a * standard colormap, use XmuGetColormapAllocation. * vinfo specifies visual information for a chosen visual * property specifies one of the standard colormap property names * red_max returns maximum red value * green_max returns maximum green value * blue_max returns maximum blue value * * XmuGetColormapAllocation returns 0 on failure, non-zero on success. * It is assumed that the visual is appropriate for the colormap property. */ Status XmuGetColormapAllocation(vinfo, property, red_max, green_max, blue_max) XVisualInfo *vinfo; Atom property; unsigned long *red_max, *green_max, *blue_max; { Status status = 1; if (vinfo->colormap_size <= 2) return 0; switch (property) { case XA_RGB_DEFAULT_MAP: status = default_allocation(vinfo, red_max, green_max, blue_max); break; case XA_RGB_BEST_MAP: besth4He XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]CMAPALLOC.C;1OP _allocation(vinfo, red_max, green_max, blue_max); break; case XA_RGB_GRAY_MAP: gray_allocation(vinfo->colormap_size, red_max, green_max, blue_max); break; case XA_RGB_RED_MAP: *red_max = vinfo->colormap_size - 1; *green_max = *blue_max = 0; break; case XA_RGB_GREEN_MAP: *green_max = vinfo->colormap_size - 1; *red_max = *blue_max = 0; break; case XA_RGB_BLUE_MAP: *blue_max = vinfo->colormap_size - 1; *red_max = *green_max = 0; break; default: status = 0; } return status; } /****************************************************************************/ /* Determine the appropriate color allocations of a gray scale. * * Keith Packard, MIT X Consortium */ static void gray_allocation(n, red_max, green_max, blue_max) int n; /* the number of cells of the gray scale */ unsigned long *red_max, *green_max, *blue_max; { *red_max = (n * 30) / 100; *green_max = (n * 59) / 100; *blue_max = (n * 11) / 100; *green_max += ((n - 1) - (*red_max + *green_max + *blue_max)); } /****************************************************************************/ /* Determine an appropriate color allocation for the RGB_DEFAULT_MAP. * If a map has less than a minimum number of definable entries, we do not * produce an allocation for an RGB_DEFAULT_MAP. * * For 24 planes, the default colormap will have 64 reds, 64 greens, and 64 * blues. For 8 planes, let n = the number of colormap entries, which may * be 256 or 254. Then, maximum red value = floor(cubis  XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]CMAPALLOC.C;1O͓ e_root(n - 125)) - 1. * Maximum green and maximum blue values are identical to maximum red. * This leaves at least 125 cells which clients can allocate. * * Return 0 if an allocation has been determined, non-zero otherwise. */ #define cube_root(n) (pow((double) (n), (double) 1.0/3.0)) static int default_allocation(vinfo, red, green, blue) XVisualInfo *vinfo; unsigned long *red, *green, *blue; { int ngrays; /* number of gray cells */ if (vinfo->colormap_size < 250) /* skip it */ return 0; switch (vinfo->class) { case PseudoColor: case DirectColor: if (vinfo->colormap_size > 500000) /* intended for displays with 24 planes */ *red = *green = *blue = (unsigned long) 63; else if (vinfo->colormap_size > 4000) /* intended for displays with 12 planes */ *red = *green = *blue = (unsigned long) 12; else /* intended for displays with 8 planes */ *red = *green = *blue = (unsigned long) (floor(cube_root(vinfo->colormap_size - 125)) - 1); break; case GrayScale: if (vinfo->colormap_size > 5000000) ngrays = 4096; else if (vinfo->colormap_size > 4000) ngrays = 512; else ngrays = 12; gray_allocation(ngrays, red, green, blue); break; default: return 0; } return 1; } /****************************************************************************/ /* Determine an appropriate color allocation for the RGB_BEST_MAP. * * For a DirectColor or TrueColor visual, the allocation is determined * by the red_mask,j XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]CMAPALLOC.C;1Oiy green_mask, and blue_mask members of the visual info. * * Otherwise, if the colormap size is an integral power of 2, determine * the allocation according to the number of bits given to each color, * with green getting more than red, and red more than blue, if there * are to be inequities in the distribution. If the colormap size is * not an integral power of 2, let n = the number of colormap entries. * Then maximum red value = floor(cube_root(n)) - 1; * maximum blue value = floor(cube_root(n)) - 1; * maximum green value = n / ((# red values) * (# blue values)) - 1; * Which, on a GPX, allows for 252 entries in the best map, out of 254 * defineable colormap entries. */ static void best_allocation(vinfo, red, green, blue) XVisualInfo *vinfo; unsigned long *red, *green, *blue; { if (vinfo->class == DirectColor || vinfo->class == TrueColor) { *red = vinfo->red_mask; while ((*red & 01) == 0) *red >>= 1; *green = vinfo->green_mask; while ((*green & 01) == 0) *green >>=1; *blue = vinfo->blue_mask; while ((*blue & 01) == 0) *blue >>= 1; } else { register int bits, n; /* Determine n such that n is the least integral power of 2 which is * greater than or equal to the number of entries in the colormap. */ n = 1; bits = 0; while (vinfo->colormap_size > n) { n = n << 1; bits++; } /* If the number of entries in the colormap is a power of 2, determine * the allocation by "dealing" the bits, first to green, then red, then * kcy XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]CMAPALLOC.C;1Oblue. If not, find the maximum integral red, green, and blue values * which, when multiplied together, do not exceed the number of * colormap entries. */ if (n == vinfo->colormap_size) { register int r, g, b; b = bits / 3; g = b + ((bits % 3) ? 1 : 0); r = b + (((bits % 3) == 2) ? 1 : 0); *red = 1 << r; *green = 1 << g; *blue = 1 << b; } else { *red = (int) floor(pow((double) vinfo->colormap_size, (double) 1.0/3.0)); *blue = *red; *green = (vinfo->colormap_size / ((*red) * (*blue))); } (*red)--; (*green)--; (*blue)--; } return; } #*[MAHAN.XTERM.LIB.XMU]CONVERTERS.H;1+,r . /@ 4 #lF-r 0123KPWO 56#lF70F87|9G@HJln XTERM021.BCKr r #[MAHAN.XTERM.LIB.XMU]CONVERTERS.H;1 w/* * $XConsortium: Converters.h,v 1.3 89/10/09 16:25:30 jim Exp $ * * Copyright 1988 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. * * The X Window System is a Trademark of MIT. * * The interfaces described by this header file are for miscellaneous utilities * and are not part of the Xlib standard. */ #ifndef _XMU_STRCONVERT_H_ #define _XMU_STRCONVERT_H_ /* * Converters - insert in alphabetical order */ /****************************************************************************** * XmuCvtFunctionToCallback */ extern void XmuCvtFunctionToCallback(); /****************************************************************************** * XmuCvtStringToBackingStore */ #define XtNbackingStore "backingStore" #define XtCBackingStore "BackingStore" #define XtRBackingStore "BackingStore" #define XtEnotUseful "notUseful" #define XtEwhenMapped "whenMapped" #define XtEalways "always" #m  XTERM021.BCKr r #[MAHAN.XTERM.LIB.XMU]CONVERTERS.H;1 define XtEdefault "default" extern void XmuCvtStringToBackingStore(); /****************************************************************************** * XmuCvtStringToCursor */ extern void XmuCvtStringToCursor(); /****************************************************************************** * XmuCvtStringToJustify */ typedef enum { XtJustifyLeft, /* justify text to left side of button */ XtJustifyCenter, /* justify text in center of button */ XtJustifyRight /* justify text to right side of button */ } XtJustify; #define XtEleft "left" #define XtEcenter "center" #define XtEright "right" extern void XmuCvtStringToJustify(); /****************************************************************************** * XmuCvtStringToLong */ #define XtRLong "Long" extern void XmuCvtStringToLong(); /****************************************************************************** * XmuCvtStringToOrientation */ typedef enum {XtorientHorizontal, XtorientVertical} XtOrientation; extern void XmuCvtStringToOrientation(); /****************************************************************************** * XmuCvtStringToBitmap */ extern void XmuCvtStringToBitmap(); /****************************************************************************** * XmuCvtStringToShapeStyle; is XtTypeConverter (i.e. new style) * no conversion arguments, not particularly useful to cache the results. */ #define XtRShapeStyle "ShapeStyle" #define XtERectangle "Rectangle" #define XtEOval "Oval" #define XtEn  XTERM021.BCKr r #[MAHAN.XTERM.LIB.XMU]CONVERTERS.H;1 NbEllipse "Ellipse" #define XtERoundedRectangle "RoundedRectangle" #define XmuShapeRectangle 1 #define XmuShapeOval 2 #define XmuShapeEllipse 3 #define XmuShapeRoundedRectangle 4 extern Boolean XmuCvtStringToShapeStyle(); extern Boolean XmuReshapeWidget( /* Widget w, int shape_style, int corner_width, int corner_height */ ); /****************************************************************************** * XmuCvtStringToWidget */ extern void XmuCvtStringToWidget(); #endif /* _XMU_STRCONVERT_H_ */ *[MAHAN.XTERM.LIB.XMU]CRCMAP.C;1+,r.#/@ 4O# 1F-r 0123KPWO!561F7zF808}9G@HJow XTERM021.BCKrr [MAHAN.XTERM.LIB.XMU]CRCMAP.C;1.C;3O#/* $XConsortium: CrCmap.c,v 1.2 89/05/24 11:05:36 converse Exp $ * * CreateCmap.c - given a standard colormap description, make the map. * * Copyright 1989 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. * * 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: Donna Converse, MIT X Consortium */ #include #ifdef vax11c #include #include #else #include #include #endif /* vax11c */ extern char *calloc(p< zib O)" o;UH6q=P]d#vnFoR[@ewmhPx~[>7)S LOOj)2y]uiY]Oc ! ?u=* _.e/%)~HWg{ AQc~fN" ~A YeBHSPQvZv\8.R=q QK X'h}M Y;&v* cHIC "H0']Lwzl~A(BYoj؉ d8ipS^@+vH x!d?71'_qF+PmRQ +3T Zh\465aIC% wa!hx[x '%JY]{Qy274:xw7kC bq;RTi3r{P ay!Yd[!%s lB/IjkZGrqjK#2A\Yj>mVS7=@QYb. FE_AW Kw>EJ |MyldKc0K%*.i_*}I5g;An1Ve*i jwjU~85Q u\1.xkJnN4jaRI?l7-w==oW qtA7L5g# ;SLns$G1ane-$b 2jFf>+k3NGhfuublr+iAMX5,>i(YHze8{kS>BtvU(PdA|1vfUpvv9?cab2RWZYSNL8IM0 YNZ YUkPLZP3[XJMiI?  }EcD{(/(f($pxK+21MhT;GD?TOmP#H\@u,@B{p'UFGO@ V=^Jtb-rVrGp' &>GJ'} wFx%),uI!2(`fG3e eP_ [$VmV+kW;nJMT\O/NDUA/,QHH _ML|sfH;lc{Y/:~\|lREfdeE|N`S{<`WQ1#,mZ^n+"xeRty;km@Kq"j~lnV8 i8S~8CW-JJ'(q<= oyCG^pf0;Ati tP`Ko$#[`%S)bRXBFH5MTJ A'yBm`yFgwtXhw`:[,4!\"yA+wfm`D#B3#V3 Ba3(('/i"lg+Y2y ETm7DQ>CN va%bJ"O/Z;*.OuzXO}[]#y2NwXl-e"xZo/bhhnYkV<*OKW :I!K!73_e)afCo(gUHDx&K^Wh'"BK$"pe]g=!44m/ޱvisualid; vinfo_mask = VisualIDMask; if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL) return 0; /* As I understand it, there may be multiple visuals with identical * visual id's at different depths. Arbitrarily, use the deepest one. */ vpointer = vinfo; if (n > 1) { register int i; unsigned int maxdepth = 0; XVisualInfo *v; for (i=0; i < n; i++, vinfo++) if (vinfo->depth > maxdepth) { maxdepth = vinfo->depth; v = vinfo; } vinfo = v; } if (vinfo->class == PseudoColor || vinfo->class == DirectColor || vinfo->class == GrayScale) status = readwrite_map(dpy, vinfo, colormap); else status = readonly_map(dpy, vinfo, colormap); XFree((char *) vpointer); return status; } /****************************************************************************/ static Status readwrite_map(dpy, vinfo, colors[ XTERM021.BCKrr [MAHAN.XTERM.LIB.XMU]CRCMAP.C;1.C;3O#\< map) Display *dpy; XVisualInfo *vinfo; XStandardColormap *colormap; { register int i, n; /* index counters */ int ncolors; /* number of colors to be defined */ int npixels; /* number of pixels allocated R/W */ int first_index; /* first index of pixels to use */ int remainder; /* first index of remainder */ XColor color; /* the definition of a color */ unsigned long *pixels; /* array of colormap pixels */ /* Determine ncolors, the number of colors to be defined. * Insure that 1 < ncolors <= the colormap size. */ ncolors = colormap->red_max * colormap->red_mult + colormap->green_max * colormap->green_mult + colormap->blue_max * colormap->blue_mult + 1; if (ncolors <= 1 || ncolors > vinfo->colormap_size) return 0; /* Allocate Read/Write as much of the colormap as we can possibly get. * Then insure that the pixels we were allocated are given in * monotonically increasing order, using a quicksort. Next, insure * that our allocation includes a subset of contiguous pixels at least * as long as the number of colors to be defined. Now we know that * these conditions are met: * 1) There are no free cells in the colormap. * 2) We have a contiguous sequence of pixels, monotonically * increasing, of length >= the number of colors requested. * * One cell at a time, we will free, compute the next color value, * then allocate read only. This takes a long time. te XTERM021.BCKrr [MAHAN.XTERM.LIB.XMU]CRCMAP.C;1.C;3O#0 * This is done to insure that cells are allocated read only in the * contiguous order which we prefer. If the server has a choice of * cells to grant to an allocation request, the server may give us any * cell, so that is why we do these slow gymnastics. */ if ((pixels = (unsigned long *) calloc((unsigned) vinfo->colormap_size, sizeof(unsigned long))) == NULL) return 0; if ((npixels = ROmap(dpy, colormap->colormap, pixels, vinfo->colormap_size, ncolors)) == 0) { free((char *) pixels); return 0; } qsort((char *) pixels, npixels, sizeof(unsigned long), compare); if (! contiguous(pixels, npixels, ncolors, &first_index, &remainder)) { /* can't find enough contiguous cells, give up */ XFreeColors(dpy, colormap->colormap, pixels, npixels, (unsigned long) 0); free((char *) pixels); return 0; } colormap->base_pixel = pixels[first_index]; /* construct a gray map */ if (colormap->red_mult == 1 && colormap->green_mult == 1 && colormap->blue_mult == 1) for (n=colormap->base_pixel, i=0; i < ncolors; i++, n++) { color.pixel = (unsigned long) n; color.blue = color.green = color.red = (unsigned short) ((i * 65535) / (colormap->red_max + colormap->green_max + colormap->blue_max)); if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, first_index + i, n)) return 0; } /* construct a red ramp map */ else if (colormap->green_max == 0 && colormap->blue_max == 0) fouH XTERM021.BCKrr [MAHAN.XTERM.LIB.XMU]CRCMAP.C;1.C;3O#r (n=colormap->base_pixel, i=0; i < ncolors; i++, n++) { color.pixel = (unsigned long) n; color.red = (unsigned short) ((i * 65535) / colormap->red_max); color.green = color.blue = 0; if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, first_index + i, n)) return 0; } /* construct a green ramp map */ else if (colormap->red_max == 0 && colormap->blue_max == 0) for (n=colormap->base_pixel, i=0; i < ncolors; i++, n++) { color.pixel = (unsigned long) n; color.green = (unsigned short) ((i * 65535) / colormap->green_max); color.red = color.blue = 0; if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, first_index + i, n)) return 0; } /* construct a blue ramp map */ else if (colormap->red_max == 0 && colormap->green_max == 0) for (n=colormap->base_pixel, i=0; i < ncolors; i++, n++) { color.pixel = (unsigned long) n; color.blue = (unsigned short) ((i * 65535) / colormap->blue_max); color.red = color.green = 0; if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, first_index + i, n)) return 0; } /* construct a standard red green blue cube map */ else { int r = colormap->red_mult; int g = colormap->green_mult; int gg = colormap->green_max + 1; for (n=colormap->base_pixel, i=0; i < ncolors; i++, n++) { color.pixel = (unsigned long) n; color.red = (unsigned short) (((i/r) * 65535) / colormap->red_max); color.green = (uvwG9 XTERM021.BCKrr [MAHAN.XTERM.LIB.XMU]CRCMAP.C;1.C;3O#Cnsigned short) ((((i/g)%gg) * 65535) / colormap->green_max); color.blue = (unsigned short) (((i%g) * 65535) / colormap->blue_max); if (! ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, first_index + i, n)) return 0; } } /* We have a read-only map defined. Now free unused cells, * first those occuring before the contiguous sequence begins, * then any following the contiguous sequence. */ if (first_index) XFreeColors(dpy, colormap->colormap, pixels, first_index, (unsigned long) 0); if (remainder) XFreeColors(dpy, colormap->colormap, &(pixels[first_index + ncolors]), remainder, (unsigned long) 0); free((char *) pixels); return 1; } /****************************************************************************/ static int ROmap(dpy, cmap, pixels, m, n) Display *dpy; /* the X server connection */ Colormap cmap; /* specifies colormap ID */ unsigned long pixels[]; /* returns pixel allocations */ int m; /* specifies colormap size */ int n; /* specifies number of colors */ { register int p; /* first try to allocate the entire colormap */ if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL, (unsigned) 0, pixels, (unsigned) m)) return m; /* Allocate all available cells in the colormap, using a binary * algorithm to discover how many cells we can allocate in the colormap. */ m--; while (n <= m) { p = n + ((m - n + 1) / 2); if (XAllwL{ XTERM021.BCKrr [MAHAN.XTERM.LIB.XMU]CRCMAP.C;1.C;3O#.ocColorCells(dpy, cmap, 1, (unsigned long *) NULL, (unsigned) 0, pixels, (unsigned) p)) { if (p == m) return p; else { XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0); n = p; } } else m = p - 1; } return 0; } /****************************************************************************/ static Status contiguous(pixels, npixels, ncolors, first, rem) unsigned long pixels[]; /* specifies allocated pixels */ int npixels; /* specifies count of alloc'd pixels */ int ncolors; /* specifies needed sequence length */ int *first; /* returns first index of sequence */ int *rem; /* returns first index after sequence, * or 0, if none follow */ { register int i = 1; /* walking index into the pixel array */ register int count = 1; /* length of sequence discovered so far */ *rem = npixels - 1; *first = 0; while (count < ncolors && ncolors - count <= *rem) { if (pixels[i-1] + 1 == pixels[i]) count++; else { count = 1; *first = i; } i++; (*rem)--; } if (count != ncolors) return 0; return 1; } /****************************************************************************/ static Status ROorRWcell(dpy, cmap, pixels, npixels, color, p, n) Display *dpy; Colormap cmap; unsigned long pixels[]; int npixels; XColor *color; int p; int n; { unsigned long pixel; XColor request; /* Free the read/write allocation of one cell in the colormap. xe XTERM021.BCKrr [MAHAN.XTERM.LIB.XMU]CRCMAP.C;1.C;3O#Z * Request a read only allocation of one cell in the colormap. * If the read only allocation cannot be granted, give up, because * there must be no free cells in the colormap. * If the read only allocation is granted, but gives us a cell which * is not the one that we just freed, it is probably the case that * we are trying allocate White or Black or some other color which * already has a read-only allocation in the map. So we try to * allocate the previously freed cell with a read/write allocation, * because we want contiguous cells for image processing algorithms. */ pixel = (unsigned long) n; request.red = color->red; request.green = color->green; request.blue = color->blue; XFreeColors(dpy, cmap, &pixel, 1, (unsigned long) 0); if (! XAllocColor(dpy, cmap, color) || (color->pixel != pixel && (!RWcell(dpy, cmap, color, &request, &pixel, n)))) { free_cells(dpy, cmap, pixels, npixels, p); return 0; } return 1; } /****************************************************************************/ static void free_cells(dpy, cmap, pixels, npixels, p) Display *dpy; Colormap cmap; unsigned long pixels[]; /* to be freed */ int npixels; /* original number allocated */ int p; { /* One of the npixels allocated has already been freed. * p is the index of the freed pixel. * First free the pixels preceeding p, and there are p of them; * then free the pixels following py F XTERM021.BCKrr [MAHAN.XTERM.LIB.XMU]CRCMAP.C;1.C;3O#, there are npixels - p - 1 of them. */ XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0); XFreeColors(dpy, cmap, &(pixels[p+1]), npixels - p - 1, (unsigned long) 0); free((char *) pixels); } /****************************************************************************/ static Status RWcell(dpy, cmap, color, request, pixel, n) Display *dpy; Colormap cmap; XColor *color; XColor *request; unsigned long *pixel; int n; { XFreeColors(dpy, cmap, &(color->pixel), 1, (unsigned long)0); if (! XAllocColorCells(dpy, cmap, (Bool) 0, (unsigned long *) NULL, (unsigned) 0, pixel, (unsigned) 1)) return 0; if (*pixel != n) { XFreeColors(dpy, cmap, pixel, 1, (unsigned long) 0); return 0; } color->pixel = *pixel; color->flags = DoRed | DoGreen | DoBlue; color->red = request->red; color->green = request->green; color->blue = request->blue; XStoreColors(dpy, cmap, color, 1); return 1; } /****************************************************************************/ static int compare(e1, e2) unsigned long *e1, *e2; { if (*e1 < *e2) return -1; if (*e1 > *e2) return 1; return 0; } /****************************************************************************/ static Status readonly_map(dpy, vinfo, colormap) Display *dpy; XVisualInfo *vinfo; XStandardColormap *colormap; { int i, last_pixel; XColor color; last_pixel = (colormap->red_max + 1) * (colormap->green_max + 1) * (colormaz߷L XTERM021.BCKrr [MAHAN.XTERM.LIB.XMU]CRCMAP.C;1.C;3O#&)p->blue_max + 1) + colormap->base_pixel - 1; for(i=colormap->base_pixel; i <= last_pixel; i++) { color.pixel = (unsigned long) i; color.red = (unsigned short) (((i/colormap->red_mult) * 65535) / colormap->red_max); if (vinfo->class == StaticColor || vinfo->class == TrueColor) { color.green = (unsigned short) ((((i/colormap->green_mult) % (colormap->green_max + 1)) * 65535) / colormap->green_max); color.blue = (unsigned short) (((i%colormap->green_mult) * 65535) / colormap->blue_max); } else /* vinfo->class == GrayScale, old style allocation XXX */ color.green = color.blue = color.red; XAllocColor(dpy, colormap->colormap, &color); if (color.pixel != (unsigned long) i) return 0; } return 1; } "*[MAHAN.XTERM.LIB.XMU]CRPIXFBIT.C;1+,r ./@ 4KȸF-r 0123KPWO56ȸF7zF80 }9G@HJ{); KZ o)o zULGJt'WoC"Ji juA0U1aZdLdw2f(<:es&aj 3>Ya[53yEy#@\.`W9k%B R 5({61'+T5w)bQ4 z; SG|h%c}m, V1X}w0p$e;?'LU*n?=DSlqRCuU\Pi4il U -$*8Y$Z)>{`]'8Q+;g?|w(VGnI^F]#Wt$o ?:@J-i3U s&fL=%6DS xMG]+]a5 0MDU1 xy:?/_Dd DZBpppP[^TFd_e{LUt=jYjdz_Fg _LWlieOCViFVU8N 'vr%RWFXw7  rONRE>Q~ 6B*13JnmurSO$QX,G{qp> KCe4oh:7:yfN4D .3\dy}\Z8!zQPOca]Y~AF1_0)5YMMT\UX-'^@%VL_hn)M|Ls_9jg(8W/ O\R|<5dN(BK D502r5^H<_10`[-N My'uSATwP* yY"=xrC ~0nHRiq[2dO{V6/'9t{URd+#>Y[DWt D]_2]Y?qrC/*>5*rdp{8YTra|/QJC0='c_' Ct1#rAJWSJyMBV R>& nS X~pcXg!iXy6wn{EQaR6ft`%A19IthozxO5v!,Zymry~sJgdfkvi0wF48rQ3'c>=)7="DQ1'0w>kEqYg[ *fn 6I;d^ KH/Fa{j==rhi0gfA kg-J|C[sxux~&>~1jB@ij#fj'@;Fz{ R.}1H:m`#nb*o-BDS$ jBd9 ? 9c蒯tK+,s::?4K$7Y5fZCgZL f'&t -8XVib=u*e$Z}:;ag3zJY}_k%d5#aVBb6!5kP+hiPs}qSCR0F C<,pN)/ KqI6*>#P91|o wXM +4)n@K" Ws=w/"g ~xY"F}8=} CvejLx3#B1;\:W(>7ZPW%i Z_IF%JybBc-0=rokEC? #FF&W&xps>VW.b^j 1E$,.t*,w)I{p3aNzSKfl'i=87mJ :)b%S/e1.go+'d&W;G382_c$=6t[][/i1 mW| XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]CRPIXFBIT.C;13K /* * $XConsortium: CrPixFBit.c,v 1.2 89/12/12 18:43:12 jim Exp $ * * Copyright 1988 Massachusetts Institute of Technology * * This file contains miscellaneous utility routines and is not part of the * Xlib standard. * * Public entry points: * * XmuCreatePixmapFromBitmap make a pixmap from a bitmap */ #ifndef vax11c #include #endif /* !vax11c */ #ifdef vax11c #include #include #else #include #include #endif /* vax11c */ Pixmap XmuCreatePixmapFromBitmap (dpy, d, bitmap, width, height, depth, fore, back) Display *dpy; /* connection to X server */ Drawable d; /* drawable indicating screen */ Pixmap bitmap; /* single plane pixmap */ unsigned int width, height; /* dimensions of bitmap and pixmap */ unsigned int depth; /* depth of pixmap to create */ unsigned long fore, back; /* colors to use */ { Pixmap pixmap; pixmap = XCreatePixmap (dpy, d, width, height, depth); if (pixmap != None) { GC gc; XGCValues xgcv; xgcv.foreground = fore; xgcv.background = back; xgcv.graphics_exposures = False; gc = XCreateGC (dpy, d, (GCForeground | GCBackground | GCGraphicsExposures), &xgcv); if (gc) { XCopyPlane (dpy, bitmap, pixmap, gc, 0, 0, width, height, 0, 0, 1); XFreeGC (dpy, gc); } else { XFreePixmap (dpy, pixmap); pixmap = None; } } return pixmap; } }5  XTERM021.BCKr r #[MAHAN.XTERM.LIB.XMU]CURSORNAME.C;2O (#*[MAHAN.XTERM.LIB.XMU]CURSORNAME.C;2+,r . /@ 4O `\F-r 0123KPWO 56`\F7F8P~9G@HJ/* * $XConsortium: CursorName.c,v 1.3 89/07/19 17:16:10 converse 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. * * 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 RESULTIN~BY XTERM021.BCKr r #[MAHAN.XTERM.LIB.XMU]CURSORNAME.C;2O *G 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. */ #ifdef vax11c #include #include "CHARSET.H" #include "CURUTIL.H" #include #else #include #include #include #include #include #endif /* vax11c */ int XmuCursorNameToIndex (name) char *name; { static struct _CursorName { char *name; unsigned int shape; } cursor_names[] = { {"x_cursor", XC_X_cursor}, {"arrow", XC_arrow}, {"based_arrow_down", XC_based_arrow_down}, {"based_arrow_up", XC_based_arrow_up}, {"boat", XC_boat}, {"bogosity", XC_bogosity}, {"bottom_left_corner", XC_bottom_left_corner}, {"bottom_right_corner", XC_bottom_right_corner}, {"bottom_side", XC_bottom_side}, {"bottom_tee", XC_bottom_tee}, {"box_spiral", XC_box_spiral}, {"center_ptr", XC_center_ptr}, {"circle", XC_circle}, {"clock", XC_clock}, {"coffee_mug", XC_coffee_mug}, {"cross", XC_cross}, {"cross_reverse", XC_cross_reverse}, {"crosshair", XC_crosshair}, {"diamond_cross", XC_diamond_cross}, {"dot", XC_dot}, {"dotbox", XC_dotbox}, {"double_arrow", XC_double_arrow}, {"draft_large", XC_draft_large}, {"draft_small", XC_draft_small}, {"draped_box", XC_draped_box}, {"exchange", XC_exchange}, {"f XTERM021.BCKr r #[MAHAN.XTERM.LIB.XMU]CURSORNAME.C;2O leur", XC_fleur}, {"gobbler", XC_gobbler}, {"gumby", XC_gumby}, {"hand1", XC_hand1}, {"hand2", XC_hand2}, {"heart", XC_heart}, {"icon", XC_icon}, {"iron_cross", XC_iron_cross}, {"left_ptr", XC_left_ptr}, {"left_side", XC_left_side}, {"left_tee", XC_left_tee}, {"leftbutton", XC_leftbutton}, {"ll_angle", XC_ll_angle}, {"lr_angle", XC_lr_angle}, {"man", XC_man}, {"middlebutton", XC_middlebutton}, {"mouse", XC_mouse}, {"pencil", XC_pencil}, {"pirate", XC_pirate}, {"plus", XC_plus}, {"question_arrow", XC_question_arrow}, {"right_ptr", XC_right_ptr}, {"right_side", XC_right_side}, {"right_tee", XC_right_tee}, {"rightbutton", XC_rightbutton}, {"rtl_logo", XC_rtl_logo}, {"sailboat", XC_sailboat}, {"sb_down_arrow", XC_sb_down_arrow}, {"sb_h_double_arrow", XC_sb_h_double_arrow}, {"sb_left_arrow", XC_sb_left_arrow}, {"sb_right_arrow", XC_sb_right_arrow}, {"sb_up_arrow", XC_sb_up_arrow}, {"sb_v_double_arrow", XC_sb_v_double_arrow}, {"shuttle", XC_shuttle}, {"sizing", XC_sizing}, {"spider", XC_spider}, {"spraycan", XC_spraycan}, {"star", XC_star}, {"target", XC_target}, {"tcross", XC_tcross}, {"top_left_arrow", XC_top_left_arrow}, {"top_left_corner", XC_top_left_corner}, {"top_right_corner", XC_top_right_corner}, {"top_side", XC_top_side}, {"top_tee", XC_top_tee}, {"trek", XC_trek}, {"ul_angle", XC_ul_angle}, {"umbrella", XC_umbrella}, {"ur_ang XTERM021.BCKr r #[MAHAN.XTERM.LIB.XMU]CURSORNAME.C;2O . le", XC_ur_angle}, {"watch", XC_watch}, {"xterm", XC_xterm}, }; register struct _CursorName *table; register int i; char tmp[40]; if (strlen (name) >= sizeof tmp) return -1; XmuCopyISOLatin1Lowered (tmp, name); for (i=0, table=cursor_names; i < XtNumber(cursor_names); i++, table++ ) { if (strcmp(tmp, table->name) == 0) return table->shape; } return -1; }  *[MAHAN.XTERM.LIB.XMU]CURUTIL.H;1+,r./@ 4"F-r 0123KPWO56F7F8PJ~9G@HJ/* * $XConsortium: CurUtil.h,v 1.1 89/07/19 15:40:17 jim Exp $ * * Copyright 1988 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 publ}" XTERM021.BCKrr  [MAHAN.XTERM.LIB.XMU]CURUTIL.H;1C;3a0icity 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. * * The X Window System is a Trademark of MIT. * * The interfaces described by this header file are for miscellaneous utilities * and are not part of the Xlib standard. */ #ifndef _XMU_CURUTIL_H_ #define _XMU_CURUTIL_H_ extern int XmuCursorNameToIndex(); #endif /* _XMU_CURUTIL_H_ */ !*[MAHAN.XTERM.LIB.XMU]CVTCACHE.C;4+,s . /@ 4O  -r 0123KPWO56A>7 A R8@]Ӟ9G@HJuD XTERM021.BCKs r ![MAHAN.XTERM.LIB.XMU]CVTCACHE.C;4;3O _/* * $XConsortium: CvtCache.c,v 1.5 89/11/30 18:21:32 rws 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. * * 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: Jim Fulton, MIT X Consortium */ #include #ifdef vax11c #include #include /* * Add in the definition for caddr_t since Digital decided * not to add it in TYPES.H for VAX C v3.2 */ #ifndef CADDR_T #define CADDR_T typedef char * caddr_t; #endif /* CADDR_T} XTERM021.BCKs r ![MAHAN.XTERM.LIB.XMU]CVTCACHE.C;4;3O  */ #include "CVTCACHE.H" #else #include #include #include #endif /* vax11c */ extern char *malloc(); static XmuDisplayQueue *dq = NULL; static int _CloseDisplay(), _FreeCCDQ(); /* * internal utility callbacks */ static int _FreeCCDQ (q) XmuDisplayQueue *q; { XmuDQDestroy (dq); dq = NULL; } static int _CloseDisplay (q, e) XmuDisplayQueue *q; XmuDisplayQueueEntry *e; { XmuCvtCache *c; extern void _XmuStringToBitmapFreeCache(); if (e && (c = (XmuCvtCache *)(e->data))) { _XmuStringToBitmapFreeCache (c); /* insert calls to free any cached memory */ } return 0; } static void _InitializeCvtCache (c) register XmuCvtCache *c; { extern void _XmuStringToBitmapInitCache(); _XmuStringToBitmapInitCache (c); /* insert calls to init any cached memory */ } /* * XmuCCLookupDisplay - return the cache entry for the indicated display; * initialize the cache if necessary */ XmuCvtCache *_XmuCCLookupDisplay (dpy) Display *dpy; { XmuDisplayQueueEntry *e; /* * If no displays have been added before this, create the display queue. */ if (!dq) { dq = XmuDQCreate (_CloseDisplay, _FreeCCDQ, NULL); if (!dq) return NULL; } /* * See if the display is already there */ e = XmuDQLookupDisplay (dq, dpy); /* see if it's there */ if (!e) { /* else create it */ XmuCvtCache *c = (XmuCvtCache *) malloc (sizeof (XmuCvtCache)); if (!c) return NULL; /* * Add the disv XTERM021.BCKs r ![MAHAN.XTERM.LIB.XMU]CVTCACHE.C;4;3O play to the queue */ e = XmuDQAddDisplay (dq, dpy, (caddr_t) c); if (!e) { free ((char *) c); return NULL; } /* * initialize fields in cache */ _InitializeCvtCache (c); } /* * got it */ return (XmuCvtCache *)(e->data); } !*[MAHAN.XTERM.LIB.XMU]CVTCACHE.H;2+,r ./@ 4O`0kF-r 0123KPWO560kF7iF80e~9G@HJ/* * $XConsortium: CvtCache.h,v 1.3 89/11/30 18:21:42 rws 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 per=r+ XTERM021.BCKr r ![MAHAN.XTERM.LIB.XMU]CVTCACHE.H;2;3O\taining 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. * * * Public Interfaces * * XmuCvtCache *XmuCvtCacheLookupDisplay (dpy) * Display *dpy; */ #ifdef vax11c #include "DISPLAYQUE.H" #else #include #endif /* vax11c */ typedef struct _XmuCvtCache { struct { char **bitmapFilePath; } string_to_bitmap; /* add other per-display data that needs to be cached */ } XmuCvtCache; extern XmuCvtCache *_XmuCCLookupDisplay(); p gr~ K e|e];C??OJGgo 1A]6 Y';70m v0G & E&TKzXIQFadB u* ,dIdSE5i@-/is]L `vc:C(IY-C$t;Y$i(Ƶd`\Ou<|*`)5xTm%rGwKUi+lO*Ot{!$Y%f|&F.T|kfrs3%iY?-?!@]QJUAA&<(VP"*KX|hdyJT D,cxH>$9mXwx[/)#  \bwvH^Ayf[eVB^_P__W8%R>bRxK>uq M~Qt]eD#8 S6.`:V2JI u\ &@nDc$hfxA9W{@o *De/l]KR GGz:eCPTDD2qZP}FgZ qG>ea;Zz yOQOl|s@38N ~ n )v >k/?V.D*V^`.?wI.*8Ycckr/ N+'%N.nDN=^1In$w3(jr>aan;(*3>R7 M`d]aY;HD.!`slv%R\cQ"L$HyCo/SGvAT Gb:VDs/D6qZ='6TyV xr:hr/?40a^,'^W?rFYAD\t Z1,eqOS$(>V1rB f\TBMC= c;FDKJ7^=r8b7/ILl ZVL@Z5zX\^bi$ZH`?P8slSvJl+$d8 5QD Z  ZQGelw[g,sjdux(2wHC\0o_g{8fWu?NxEZ/G 0a EO!CV0mQ'C4d^?\d(%~.8s nx0-CZrT!' ;gy~8TH' X ^nDdu)rRfp{2r)4-p3lxdxQ\1`1KVS"~whAChh=!,U["ViC]@c]* pu#uW?.v=~)t5 h3^.1s-M0vH qMGk3cm@Ja/&iq~crahga@,5_t< -w&:/*uth_@MK0#WRJEkW M pRQN%06<)y7SP}Zs25&D #endif /* !vax11c */ #ifdef att #include #define __TYPES__ /* prevent #including in Xlib.h */ #include #include #endif /* att */ #ifdef vax11c #include #include #include #include #else #include #include #include #include #endif /* vax11c */ #include #ifndef att #ifndef vax11c #include #include #endif /* !vax11c */ #endif #ifdef vax11c #include "XMU.H" #else #include "Xmu.h" #endif /* vax11c */ #if defined(SUNSHLP0ݍ XTERM021.BCKrr "[MAHAN.XTERM.LIB.XMU]CVTSTDSEL.C;23EבIB) && defined(SHAREDCODE) /* * hack to avoid undefined symbol errors at runtime */ extern WidgetClass get_applicationShellWidgetClass(); extern WidgetClass get_wmShellWidgetClass(); #else #define get_applicationShellWidgetClass() applicationShellWidgetClass #define get_wmShellWidgetClass() wmShellWidgetClass #endif static char *get_os_name () { #ifdef OS_NAME return XtNewString(OS_NAME); #else FILE *f = NULL; #if !defined(X_OS_FILE) #ifdef SYSV /* keep separate until makedepend fixed */ #define USE_UNAME #endif #ifdef ultrix #define USE_UNAME #endif #endif /*X_OS_FILE*/ #ifdef USE_UNAME #ifdef ultrix #include /* fixed in Ultrix 3.0 */ #endif #include struct utsname uts; if (uname (&uts) == 0) { char *os_name; int len = strlen(uts.sysname); #ifndef hpux /* because of hostname length crock */ len += 1 + strlen(uts.release); #endif os_name = XtMalloc (len); strcpy (os_name, uts.sysname); #ifndef hpux strcat (os_name, " "); strcat (os_name, uts.release); #endif return os_name; } #endif #ifdef X_OS_FILE f = fopen(X_OS_FILE, "r"); if (!f) #endif #ifdef MOTD_FILE f = fopen(MOTD_FILE, "r"); #endif if (f) { char motd[512]; motd[0] = '\0'; (void) fgets(motd, 511, f); fclose(f); motd[511] = '\0'; if (motd[0] != '\0') { int len = strlen(motd); if (motd[len - 1] == '\n') motd[len - 1] = '\0'; return XtNewString(motd); } } #ifdef sun return XtNewString("SunOS"); #else # if !defin  XTERM021.BCKrr "[MAHAN.XTERM.LIB.XMU]CVTSTDSEL.C;23EJed(SYSV) && defined(unix) return XtNewString("BSD"); # else return NULL; # endif #endif #endif /*OS_NAME*/ } Boolean XmuConvertStandardSelection(w, time, selection, target, type, value, length, format) Widget w; Time time; Atom *selection, *target, *type; caddr_t *value; unsigned long *length; int *format; { Display *d = XtDisplay(w); if (*target == XA_TIMESTAMP(d)) { *value = XtMalloc(4); if (sizeof(long) == 4) *(long*)*value = time; else { long temp = time; bcopy( ((char*)&temp)+sizeof(long)-4, (char*)*value, 4); } *type = XA_INTEGER; *length = 1; *format = 32; return True; } if (*target == XA_HOSTNAME(d)) { char hostname[1024]; hostname[0] = '\0'; *length = XmuGetHostname (hostname, sizeof hostname); *value = XtNewString(hostname); *type = XA_STRING; *format = 8; return True; } #ifdef TCPCONN if (*target == XA_IP_ADDRESS(d)) { char hostname[1024]; struct hostent *hostent; hostname[0] = '\0'; (void) XmuGetHostname (hostname, sizeof hostname); hostent = gethostbyname (hostname); if (hostent->h_addrtype != AF_INET) return False; *length = hostent->h_length; *value = XtMalloc(*length); bcopy (hostent->h_addr, *value, *length); *type = XA_NET_ADDRESS(d); *format = 8; return True; } #endif #ifdef DNETCONN if (*target == XA_DECNET_ADDRESS(d)) { return False; /* XXX niy */ } #endif if (*target == XA_USER(d)) { char *name = (char*)getenv("USER"); if (name == NULL) return False; *value = XtNewSt`g XTERM021.BCKrr "[MAHAN.XTERM.LIB.XMU]CVTSTDSEL.C;22E" ring(name); *type = XA_STRING; *length = strlen(name); *format = 8; return True; } if (*target == XA_CLASS(d)) { Widget parent = XtParent(w); char *class; int len; while (parent != NULL && !XtIsSubclass(w, get_applicationShellWidgetClass())) { w = parent; parent = XtParent(w); } if (XtIsSubclass(w, get_applicationShellWidgetClass())) class = ((ApplicationShellWidget) w)->application.class; else { class = XrmQuarkToString( XtClass(w)->core_class.xrm_class ); } *length = (len=strlen(w->core.name)) + strlen(class) + 2; *value = XtMalloc(*length); strcpy( (char*)*value, w->core.name ); strcpy( (char*)*value+len+1, class ); *type = XA_STRING; *format = 8; return True; } if (*target == XA_NAME(d)) { Widget parent = XtParent(w); while (parent != NULL && !XtIsSubclass(w, get_wmShellWidgetClass())) { w = parent; parent = XtParent(w); } if (!XtIsSubclass(w, get_wmShellWidgetClass())) return False; *value = XtNewString( ((WMShellWidget) w)->wm.title ); *length = strlen(*value); *type = XA_STRING; *format = 8; return True; } if (*target == XA_CLIENT_WINDOW(d)) { Widget parent = XtParent(w); while (parent != NULL) { w = parent; parent = XtParent(w); } *value = XtMalloc(sizeof(Window)); *(Window*)*value = w->core.window; *type = XA_WINDOW; *length = 1; *format = 32; return True; } if (*target == XA_OWNER_OS(d)) { *value = get_os_name(); if (*value == NULL) return False; *type = XA_STRING; *length  XTERM021.BCKrr "[MAHAN.XTERM.LIB.XMU]CVTSTDSEL.C;22E. = strlen(*value); *format = 8; return True; } if (*target == XA_TARGETS(d)) { #if defined(unix) && defined(DNETCONN) # define NUM_TARGETS 9 #else # if defined(unix) || defined(DNETCONN) # define NUM_TARGETS 8 # else # define NUM_TARGETS 7 # endif #endif Atom* std_targets = (Atom*)XtMalloc(NUM_TARGETS*sizeof(Atom)); int i = 0; std_targets[i++] = XA_TIMESTAMP(d); std_targets[i++] = XA_HOSTNAME(d); std_targets[i++] = XA_IP_ADDRESS(d); std_targets[i++] = XA_USER(d); std_targets[i++] = XA_CLASS(d); std_targets[i++] = XA_NAME(d); std_targets[i++] = XA_CLIENT_WINDOW(d); #ifdef unix std_targets[i++] = XA_OWNER_OS(d); #endif #ifdef DNETCONN std_targets[i++] = XA_DECNET_ADDRESS(d); #endif *value = (caddr_t)std_targets; *type = XA_ATOM; *length = NUM_TARGETS; *format = 32; return True; } /* else */ return False; } "*[MAHAN.XTERM.LIB.XMU]DEFERRMSG.C;1+,r. /@ 4N KɻF-r 0123KPWO 56ɻF7F8A9G@HJÖF XTERM021.BCKrr "[MAHAN.XTERM.LIB.XMU]DEFERRMSG.C;12N /* * $XConsortium: DefErrMsg.c,v 1.5 89/12/13 16:17:04 rws Exp $ * * Copyright 1988 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. * */ #include #ifdef vax11c #include #include #else #include #include #endif /* vax11c */ /* * XmuPrintDefaultErrorMessage - print a nice error that looks like the usual * message. Returns 1 if the caller should consider exitting else 0. */ int XmuPrintDefaultErrorMessage (dpy, event, fp) Display *dpy; XErrorEvent *event; FILE *fp; { char buffer[BUFSIZ]; char mesg[BUFSIZ]; char number[32]; char *mtype = "XlibMessage"; register _XExtension *ext = (_XExtension *)NULL; XGetErrorText(dpy, event->error_code, buffer, BUFSIZ); XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ); (void) fprintf(fp, "%s: %s\n ", mesg, b( XTERM021.BCKrr "[MAHAN.XTERM.LIB.XMU]DEFERRMSG.C;12N | uffer); XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d", mesg, BUFSIZ); (void) fprintf(fp, mesg, event->request_code); if (event->request_code < 128) { sprintf(number, "%d", event->request_code); XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ); } else { /* XXX need an Xlib interface for this */ for (ext = dpy->ext_procs; ext && (ext->codes.major_opcode != event->request_code); ext = ext->next) ; if (ext) strcpy(buffer, ext->name); else buffer[0] = '\0'; } (void) fprintf(fp, " (%s)", buffer); fputs("\n ", fp); XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d", mesg, BUFSIZ); (void) fprintf(fp, mesg, event->minor_code); fputs("\n ", fp); if (ext) { sprintf(mesg, "%s.%d", ext->name, event->minor_code); XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ); (void) fprintf(fp, " (%s)", buffer); } XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x", mesg, BUFSIZ); (void) fprintf(fp, mesg, event->resourceid); fputs("\n ", fp); XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d", mesg, BUFSIZ); (void) fprintf(fp, mesg, event->serial); fputs("\n ", fp); XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d", mesg, BUFSIZ); (void) fprintf(fp, mesg, NextRequest(dpy)-1); fputs("\n", fp); if (event->error_code == BadImplementation) return 0; return 1; } /* * XmuSimple; XTERM021.BCKrr "[MAHAN.XTERM.LIB.XMU]DEFERRMSG.C;12N ErrorHandler - ignore errors for XQueryTree, XGetWindowAttributes, * and XGetGeometry; print a message for everything else. In all case, do * not exit. */ int XmuSimpleErrorHandler (dpy, errorp) Display *dpy; XErrorEvent *errorp; { switch (errorp->request_code) { case X_QueryTree: case X_GetWindowAttributes: if (errorp->error_code == BadWindow) return 0; break; case X_GetGeometry: if (errorp->error_code == BadDrawable) return 0; break; } /* got a "real" X error */ return XmuPrintDefaultErrorMessage (dpy, errorp, stderr); }  *[MAHAN.XTERM.LIB.XMU]DELCMAP.C;1+,r./@ 4OμF-r 0123KPWO56μF7`rF8p9G@HJQI XTERM021.BCKrr  [MAHAN.XTERM.LIB.XMU]DELCMAP.C;1C;2O8/* $XConsortium: DelCmap.c,v 1.1 89/05/19 14:37:16 converse Exp $ * * Copyright 1989 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. * * 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: Donna Converse, MIT X Consortium */ #ifdef vax11c #include #include #else #include #include #endif /* vax11c */ /* To remove any standard colormap property, use XmuDeleteStandardColormap(). * XmuDeleteStandardColormap() wil< XTERM021.BCKrr  [MAHAN.XTERM.LIB.XMU]DELCMAP.C;1C;2Ol remove the specified property from the * specified screen, releasing any resources used by the colormap(s) of the * property if possible. */ void XmuDeleteStandardColormap(dpy, screen, property) Display *dpy; /* specifies the X server to connect to */ int screen; /* specifies the screen of the display */ Atom property; /* specifies the standard colormap property */ { XStandardColormap *stdcmaps, *s; int count = 0; if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count, property)) { for (s=stdcmaps; count > 0; count--, s++) { if ((s->killid == ReleaseByFreeingColormap) && (s->colormap != None) && (s->colormap != DefaultColormap(dpy, screen))) XFreeColormap(dpy, s->colormap); else if (s->killid != None) XKillClient(dpy, s->killid); } XDeleteProperty(dpy, RootWindow(dpy, screen), property); XFree((char *) stdcmaps); XSync(dpy, False); } } #*[MAHAN.XTERM.LIB.XMU]DISPLAYQUE.C;5+,s ./@ 4Q a-r 0123KPWO 56FA>7; R8 í9G@HJp  >Zr N43r['+ZKP.%.  8;nY'#),8q]e4>_2${_l]Ic>Pe#|xyre>yW?c1cU=)OX"c4mO3R%}Clu:ZβI *':#nQqO{dMJL'E|%3zgwoTd[ 1m1FwvJVhcRqAA4mrh.Dh:\?Z?SA0#Kx(:o>@pc|fj $&su;@QEWoNYBIoTZ+k5NNF!]5<x^E8|lYkR Z\M!1 s_U>E)B'7-~lgR qOhoJ@*giIw J"6MD>IS1.RA+AMJB:* V>.@yGnE? pJS*.X^hNkX ,b!R{Z`T/$ GD_j6AF8jjEuorLk5j HU+l0N>^<#T*SpdSD+]y{60m ahe''Q":YH1}@XxVmm, . I(L]\Bx|>[@16jG%g2.bP{}eP2d@ :0}mo-5 =| r2/ LdEp EQ3pd 'GYGP !^%} OT-Q 0)C&)Jw/ e$b\OXg V5rLbxO HzEMk+&Z`8^DzMZ(JDH zkprT#<&?I V&QFDbepW'uJ9- E{X-euaxAxT.Z(gU<H+eA 'S>&JQ!w[+[hX)*i=5` #ifdef vax11c #include #include /* * Add in the definition for caddr_t since Digital decided * not to add it in TYPES.H for VAX C v3.2 */ #ifndef CADDR_T #define CADDR_T typedef char * caddr_t; #endif /* CADDR_' XTERM021.BCKs r #[MAHAN.XTERM.LIB.XMU]DISPLAYQUE.C;5B;1QBT */ #include "DISPLAYQUE.H" #else #include #include #include #endif /* vax11c */ static int _DQCloseDisplay(); #define CallCloseCallback(q,e) (void) (*((q)->closefunc)) ((q), (e)) #define CallFreeCallback(q) (void) (*((q)->freefunc)) ((q)) /* * XmuDQCreate - create a display queue */ XmuDisplayQueue *XmuDQCreate (closefunc, freefunc, data) int (*closefunc)(); int (*freefunc)(); caddr_t data; { XmuDisplayQueue *q = (XmuDisplayQueue *) malloc (sizeof (XmuDisplayQueue)); if (q) { q->nentries = 0; q->head = q->tail = NULL; q->closefunc = closefunc; q->freefunc = freefunc; q->data = data; } return q; } /* * XmuDQDestroy - free all storage associated with this display queue, * optionally invoking the close callbacks. */ Bool XmuDQDestroy (q, docallbacks) XmuDisplayQueue *q; Bool docallbacks; { XmuDisplayQueueEntry *e = q->head; while (e) { XmuDisplayQueueEntry *nexte = e->next; if (docallbacks && q->closefunc) CallCloseCallback (q, e); free ((char *) e); e = nexte; } free ((char *) q); return True; } /* * XmuDQLookupDisplay - finds the indicated display on the given queue */ XmuDisplayQueueEntry *XmuDQLookupDisplay (q, dpy) XmuDisplayQueue *q; Display *dpy; { XmuDisplayQueueEntry *e; for (e = q->head; e; e = e->next) { if (e->display == dpy) return e; } return NULL; } /* * XmuDQAddDisplay - add the specified display to the queue; set data as a * convenience. 6> XTERM021.BCKs r #[MAHAN.XTERM.LIB.XMU]DISPLAYQUE.C;5Q6 Does not ensure that dpy hasn't already been added. */ XmuDisplayQueueEntry *XmuDQAddDisplay (q, dpy, data) XmuDisplayQueue *q; Display *dpy; caddr_t data; { XmuDisplayQueueEntry *e; if (!(e = (XmuDisplayQueueEntry *) malloc (sizeof (XmuDisplayQueueEntry)))) { return NULL; } if (!(e->closehook = XmuAddCloseDisplayHook (dpy, _DQCloseDisplay, (caddr_t) q))) { free ((char *) e); return NULL; } e->display = dpy; e->next = NULL; e->data = data; if (q->tail) { q->tail->next = e; e->prev = q->tail; } else { q->head = e; e->prev = NULL; } q->tail = e; q->nentries++; return e; } /* * XmuDQRemoveDisplay - remove the specified display from the queue */ Bool XmuDQRemoveDisplay (q, dpy) XmuDisplayQueue *q; Display *dpy; { XmuDisplayQueueEntry *e; for (e = q->head; e; e = e->next) { if (e->display == dpy) { if (q->head == e) q->head = e->next; /* if at head, then bump head */ else e->prev->next = e->next; /* else splice out */ if (q->tail == e) q->tail = e->prev; /* if at tail, then bump tail */ else e->next->prev = e->prev; /* else splice out */ (void) XmuRemoveCloseDisplayHook (dpy, e->closehook, _DQCloseDisplay, (caddr_t) q); free ((char *) e); q->nentries--; return True; } } return False; } /***************************************************************************** * private functions $ XTERM021.BCKs r #[MAHAN.XTERM.LIB.XMU]DISPLAYQUE.C;5QB * *****************************************************************************/ /* * _DQCloseDisplay - upcalled from CloseHook to notify this queue; remove the * display when finished */ static int _DQCloseDisplay (dpy, arg) Display *dpy; caddr_t arg; { XmuDisplayQueue *q = (XmuDisplayQueue *) arg; XmuDisplayQueueEntry *e; for (e = q->head; e; e = e->next) { if (e->display == dpy) { if (q->closefunc) CallCloseCallback (q, e); (void) XmuDQRemoveDisplay (q, dpy); if (q->nentries == 0 && q->freefunc) CallFreeCallback (q); return 1; } } return 0; } #*[MAHAN.XTERM.LIB.XMU]DISPLAYQUE.H;2+,r . /@ 4O C0fF-r 0123KPWO560fF70ZF8/9G@HJ6v{ XTERM021.BCKr r #[MAHAN.XTERM.LIB.XMU]DISPLAYQUE.H;2O 9/* Coopyright 1989 Massachusetts Institute of Technology */ #ifdef vax11c #include "CLOSEHOOK.H" #else #include #endif /* vax11c */ /* * Public Entry Points * * * XmuDisplayQueue *XmuDQCreate (closefunc, freefunc, data) * int (*closefunc)(); * int (*freefunc)(); * caddr_t data; * * Creates and returns a queue into which displays may be placed. When * the display is closed, the closefunc (if non-NULL) is upcalled with * as follows: * * (*closefunc) (queue, entry) * * The freeproc, if non-NULL, is called whenever the last display is * closed, notifying the creator that display queue may be released * using XmuDQDestroy. * * * Bool XmuDQDestroy (q, docallbacks) * XmuDisplayQueue *q; * Bool docallbacks; * * Releases all memory for the indicated display queue. If docallbacks * is true, then the closefunc (if non-NULL) is called for each * display. * * * XmuDisplayQueueEntry *XmuDQLookupDisplay (q, dpy) * XmuDisplayQueue *q; * Display *dpy; * * Returns the queue entry for the specified display or NULL if the * display is not in the queue. * * * XmuDisplayQueueEntry *XmuDQAddDisplay (q, dpy, data) * XmuDisplayQueue *q; * Display *dpy; * caddr_t data; * * Adds the indicated display to the end of the queue or NULL if it * is unable to allocate memory. The data field may be used &^K XTERM021.BCKr r #[MAHAN.XTERM.LIB.XMU]DISPLAYQUE.H;2O ?by the * caller to attach arbitrary data to this display in this queue. The * caller should use XmuDQLookupDisplay to make sure that the display * hasn't already been added. * * * Bool XmuDQRemoveDisplay (q, dpy) * XmuDisplayQueue *q; * Display *dpy; * * Removes the specified display from the given queue. If the * indicated display is not found on this queue, False is returned, * otherwise True is returned. */ typedef struct _XmuDisplayQueueEntry { struct _XmuDisplayQueueEntry *prev, *next; Display *display; CloseHook closehook; caddr_t data; } XmuDisplayQueueEntry; typedef struct _XmuDisplayQueue { int nentries; XmuDisplayQueueEntry *head, *tail; int (*closefunc)(); int (*freefunc)(); caddr_t data; } XmuDisplayQueue; extern XmuDisplayQueue *XmuDQCreate (); extern Bool XmuDQDestroy (); extern XmuDisplayQueueEntry *XmuDQLookupDisplay (); extern XmuDisplayQueueEntry *XmuDQAddDisplay (); extern Bool XmuDQRemoveDisplay (); #define XmuDQNDisplays(q) ((q)->nentries) Hũ XTERM021.BCKr r  [MAHAN.XTERM.LIB.XMU]DRAWING.H;1C;2C *[MAHAN.XTERM.LIB.XMU]DRAWING.H;1+,r ./@ 4 F-r 0123KPWO56 F7%0F8Pp9G@HJ/* * $XConsortium: Drawing.h,v 1.3 89/10/03 08:37:53 rws Exp $ * * Copyright 1988 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. * * The X Window System is a Trademark of MIT. * * The interfaces described by this header file are for miscellaneous utilities * and are not part of the Xlib standard. */ #ifndef _XMU_DRAWING_H_ #define _XMU_DRAWING_H_ void XmuDrawRoundedRectangle();Aط XTERM021.BCKr r  [MAHAN.XTERM.LIB.XMU]DRAWING.H;1C;2@ void XmuFillRoundedRectangle(); void XmuDrawLogo(); Pixmap XmuCreatePixmapFromBitmap(); Pixmap XmuCreateStippledPixmap(); Pixmap XmuLocateBitmapFile(); int XmuReadBitmapData(), XmuReadBitmapDataFromFile(); #endif /* _XMU_DRAWING_H_ */ !*[MAHAN.XTERM.LIB.XMU]DRAWLOGO.C;1+,r . /@ 4T F-r 0123KPWO 56F7mF8&9G@HJ#ifndef lint static char Xrcsid[] = "$XConsortium: DrawLogo.c,v 1.1 89/05/11 14:01:55 kit Exp $"; #endif #ifdef vax11c #include #else #include #endif /* vax11c */ /* Copyright 1988 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 permZ XTERM021.BCKr r ![MAHAN.XTERM.LIB.XMU]DRAWLOGO.C;1;2T Lission 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. */ /* * Draw the "official" X Window System Logo, designed by Danny Chong * * Written by Ollie Jones, Apollo Computer * * Does some fancy stuff to make the logo look acceptable even * if it is tiny. Also makes the various linear elements of * the logo line up as well as possible considering rasterization. */ XmuDrawLogo(dpy, drawable, gcFore, gcBack, x, y, width, height) Display *dpy; Drawable drawable; GC gcFore, gcBack; int x, y; unsigned int width, height; { unsigned int size; int d11, d21, d31; XPoint poly[4]; XFillRectangle(dpy, drawable, gcBack, x, y, width, height); /* for now, do a centered even-sized square, at least for now */ size = width; if (height < width) size = height; size &= ~1; x += (width - size) >> 1; y += (height - size) >> 1; /* * ----- * / / * / / * / / * / / * /____/ */ d11 = (size / 11); if (d11 < 1) d11 = 1; d21 = (d11+3) / 4; d31 = d11 + d11 + d21; poly[0].x = x + size; poly[0].y = y; poly[1].x = x + size-d31; poly[1].y = y; poly[2].x = xe9 XTERM021.BCKr r ![MAHAN.XTERM.LIB.XMU]DRAWLOGO.C;1;2DES.HINT;1T 4; + 0; poly[2].y = y + size; poly[3].x = x + d31; poly[3].y = y + size; XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin); /* * ------ * / / * / __ / * / / / * / / / * /__/__/ */ poly[0].x = x + d31/2; poly[0].y = y + size; poly[1].x = x + size / 2; poly[1].y = y + size/2; poly[2].x = x + (size/2)+(d31-(d31/2)); poly[2].y = y + size/2; poly[3].x = x + d31; poly[3].y = y + size; XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin); /* * ------ * / / / * /--/ / * / / * / / * /_____/ */ poly[0].x = x + size - d31/2; poly[0].y = y; poly[1].x = x + size / 2; poly[1].y = y + size/2; poly[2].x = x + (size/2)-(d31-(d31/2)); poly[2].y = y + size/2; poly[3].x = x + size - d31; poly[3].y = y; XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin); /* * ----- * \ \ * \ \ * \ \ * \ \ * \____\ */ poly[0].x = x; poly[0].y = y; poly[1].x = x + size/4; poly[1].y = y; poly[2].x = x + size; poly[2].y = y + size; poly[3].x = x + size - size/4; poly[3].y = y + size; XFillPolygon(dpy, drawable, gcFore, poly, 4, Convex, CoordModeOrigin); /* * 5~b.HINT;1 ~8sGdmpD]rzeBaqMK) nx'75x=OLoHuA4#{g~/nOF*V}X:E--Kxi~D3.&do3)XMKr40a3MhF,9'rd\@2w[ uA]upNE;?G/YK_5}O(cYd9'@ 2)A>3#E'ZDl}pD06n9[b~\JkJWao6Vz6C5N"w=DH IkOAN>7}T fHRT5d(P d\xqWOt$w vMMx+U.>>jTv\QxIuc)J"wB|F2EC<glD"/ gkXitQ sUe]R]`B f:d 1HYZ^P %0"#`+)~r)Kj'Pf)bsrf!_-Nq> K[vak?0VZ3Yphvko1 a9z29h)*Dw t>y3 0Mu>FdYA#Md%GW c(Crq- I[- R'\:(["snbe\D 2[_AC^mTNҮPQ[SpVb"l2(^$NjYss`ZBVfy$7h"PVeXt3j#vdEG#0I/%'mB`O4z#늊x@V9)I==^@[iXYtvM///Q%,*e" 4ozly(q+4lS:?cOe|kR+Yh*"EK=_V \okjf#PIzwGwU&"H!-!QfiXRW&"@}QXY>MS0h ,QvhsxU @LbeQ$XzBHEv ?[C)]Vvl(rD',otLnx-eT@zyhvid5 flA CMMw/ J>V z'k!wyRDU\B Pu 7$xYEaE ]0[aS% Ai^>6xyiU!B] 2/rgSIU05aj(1CN^ :QJ; X0}x~2nU\N.^$bJ;Le L|/,a)UUUHc"]vp\l\t<:9Rq_45(5w[a]ME,3G&`X0qtRYaDcza6Co^f%-u>%;Eh-3% k:J:",e+\HBq\aHkBoC1qg8]jq>6[.]O[p>/yWE^=bmn>..(+O"w`laL`MsQ^@] WZkHcBX^A@ _HWL:4D kx ?<k#z@[ ptgw3s8xCQgTi1re R:d}Xz2Ov=aq 2jX TJOnEtWUe|F^QWpPcv3I3PXu2LT#'t;Ox.D"F1PO uoSwY \4Gm x($fC] n-e=>1ne+DCROsL}+w}O } V1q"~y8'& XTERM021.BCKr r ![MAHAN.XTERM.LIB.XMU]DRAWLOGO.C;1;2T  / * / * / * / * / */ poly[0].x = x + size- d11; poly[0].y = y; poly[1].x = x + size-( d11+d21); poly[1].y = y; poly[2].x = x + d11; poly[2].y = y + size; poly[3].x = x + d11 + d21; poly[3].y = y + size; XFillPolygon(dpy, drawable, gcBack, poly, 4, Convex, CoordModeOrigin); } #ifdef XAW_BC /* * For Compatability Only. */ XDrawLogo(dpy, drawable, gcFore, gcBack, x, y, width, height) Display *dpy; Drawable drawable; GC gcFore, gcBack; int x, y; unsigned int width, height; { XmuDrawLogo(dpy, drawable, gcFore, gcBack, x, y, width, height); } #endif /* XAW_BC */ "*[MAHAN.XTERM.LIB.XMU]DRRNDRECT.C;1+,r. /@ 4H tF-r 0123KPWO56F7eڿF8瀚9G@HJO1E XTERM021.BCKrr "[MAHAN.XTERM.LIB.XMU]DRRNDRECT.C;12H /* * $XConsortium: DrRndRect.c,v 1.2 89/10/03 08:38:21 rws Exp $ * * XmuDrawRoundedRectangle, XmuFillRoundedRectangle * * Draw/Fill a rounded rectangle, where x, y, w, h are the dimensions of * the overall rectangle, and ew and eh are the sizes of a bounding box * that the corners are drawn inside of. */ #ifdef vax11c #include #else #include #endif /* vax11c */ void XmuDrawRoundedRectangle (dpy, draw, gc, x, y, w, h, ew, eh) Display *dpy; Drawable draw; GC gc; int x, y, w, h, ew, eh; { XArc arcs[8]; if (ew*2 > w) ew = 0; if (eh*2 > h) eh = 0; arcs[0].x = x; arcs[0].y = y; arcs[0].width = ew*2; arcs[0].height = eh*2; arcs[0].angle1 = 180*64; arcs[0].angle2 = -90*64; arcs[1].x = x + ew; arcs[1].y = y; arcs[1].width = w - ew*2; arcs[1].height = 0; arcs[1].angle1 = 180*64; arcs[1].angle2 = -180*64; arcs[2].x = x + w - ew*2; arcs[2].y = y; arcs[2].width = ew*2; arcs[2].height = eh*2; arcs[2].angle1 = 90*64; arcs[2].angle2 = -90*64; arcs[3].x = x + w; arcs[3].y = y + eh; arcs[3].width = 0; arcs[3].height = h - eh*2; arcs[3].angle1 = 90 * 64; arcs[3].angle2 = -180*64; arcs[4].x = x + w - ew*2; arcs[4].y = y + h - eh*2; arcs[4].width = ew * 2; arcs[4].height = eh * 2; arcs[4].angle1 = 0; arcs[4].angle2 = -90*64; arcs[5].x = x + ew; arcs[5].y = y + h; arcs[5].width = w - ew*2; arcs[5].height = 0; arcs[5].angle1 = 0; arcs[5].angle2 = -180*64; arcs[6].x = x; arcs[6].y = y + h - eh*2; arcs[6].width XTERM021.BCKrr "[MAHAN.XTERM.LIB.XMU]DRRNDRECT.C;12H f = ew*2; arcs[6].height = eh*2; arcs[6].angle1 = 270*64; arcs[6].angle2 = -90*64; arcs[7].x = x; arcs[7].y = y + eh; arcs[7].width = 0; arcs[7].height = h - eh*2; arcs[7].angle1 = 270*64; arcs[7].angle2 = -180*64; XDrawArcs (dpy, draw, gc, arcs, 8); } void XmuFillRoundedRectangle (dpy, draw, gc, x, y, w, h, ew, eh) Display *dpy; Drawable draw; GC gc; int x, y, w, h, ew, eh; { XArc arcs[4]; XRectangle rects[3]; XGCValues vals; XGetGCValues(dpy, gc, GCArcMode, &vals); if (vals.arc_mode != ArcPieSlice) XSetArcMode(dpy, gc, ArcPieSlice); if (ew*2 > w) ew = 0; if (eh*2 > h) eh = 0; arcs[0].x = x; arcs[0].y = y; arcs[0].width = ew*2; arcs[0].height = eh*2; arcs[0].angle1 = 180*64; arcs[0].angle2 = -90*64; arcs[1].x = x + w - ew*2; arcs[1].y = y; arcs[1].width = ew*2; arcs[1].height = eh*2; arcs[1].angle1 = 90*64; arcs[1].angle2 = -90*64; arcs[2].x = x + w - ew*2; arcs[2].y = y + h - eh*2; arcs[2].width = ew*2; arcs[2].height = eh*2; arcs[2].angle1 = 0; arcs[2].angle2 = -90*64; arcs[3].x = x; arcs[3].y = y + h - eh*2; arcs[3].width = ew*2; arcs[3].height = eh*2; arcs[3].angle1 = 270*64; arcs[3].angle2 = -90*64; XFillArcs (dpy, draw, gc, arcs, 4); rects[0].x = x + ew; rects[0].y = y; rects[0].width = w - ew*2; rects[0].height = h; rects[1].x = x; rects[1].y = y + eh; rects[1].width = ew; rects[1].height = h - eh*2; rects[2].x = x + w - ew; rects[2].y = y + eh; rects[2].width = ew; rects[2].height = h - eh*2; XFillRe1= XTERM021.BCKrr "[MAHAN.XTERM.LIB.XMU]DRRNDRECT.C;12H |ctangles (dpy, draw, gc, rects, 3); if (vals.arc_mode != ArcPieSlice) XSetArcMode(dpy, gc, vals.arc_mode); } *[MAHAN.XTERM.LIB.XMU]ERROR.H;1+,r ./@ 47رF-r 0123KPWO56رF7ήF8pb9G@HJ/* * $XConsortium: Error.h,v 1.2 89/11/14 16:16:30 jim Exp $ * * Copyright 1988 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 publico!5 XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]ERROR.H;1;4C;23:ity 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. * * The X Window System is a Trademark of MIT. * * The interfaces described by this header file are for miscellaneous utilities * and are not part of the Xlib standard. */ #ifndef _XMU_ERROR_H_ #define _XMU_ERROR_H_ int XmuPrintDefaultErrorMessage(); int XmuSimpleErrorHandler(); #endif /* _XMU_ERROR_H_ */ !*[MAHAN.XTERM.LIB.XMU]FTOCBACK.C;1+,r ./@ 4MYiF-r 0123KPWO56iF7 F8PM9G@HJ56 XTERM021.BCKr r ![MAHAN.XTERM.LIB.XMU]FTOCBACK.C;1;2Mstatic char rcsid[] = "$XConsortium: FToCback.c,v 1.1 89/12/07 10:52:21 rws Exp $"; /* * Copyright 1988 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. * */ #ifdef vax11c #include #else #include #endif /* vax11c */ /* ARGSUSED */ void XmuCvtFunctionToCallback(args, num_args, fromVal, toVal) XrmValue *args; /* unused */ Cardinal *num_args; /* unused */ XrmValuePtr fromVal; XrmValuePtr toVal; { static XtCallbackRec callback[2]; /* K&R: initialized to NULL */ static XtCallbackList callback_list = callback; callback[0].callback = *(XtCallbackProc *)fromVal->addr; toVal->size = sizeof(XtCallbackList); toVal->addr = (caddr_t)&callback_list; } ] XTERM021.BCKr r  [MAHAN.XTERM.LIB.XMU]GETHOST.C;1C;294 *[MAHAN.XTERM.LIB.XMU]GETHOST.C;1+,r ./@ 4F-r 0123KPWO56F7@F8y9G@HJ/* * $XConsortium: GetHost.c,v 1.1 89/09/22 12:07:36 jim Exp $ * * 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 FROMG XTERM021.BCKr r  [MAHAN.XTERM.LIB.XMU]GETHOST.C;1C;28 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: Jim Fulton, MIT X Consortium * * _XGetHostname - similar to gethostname but allows special processing. */ int XmuGetHostname (buf, maxlen) char *buf; int maxlen; { int len; #ifdef hpux /* stupid makedepend [need if] */ #define NEED_UTSNAME #endif #ifdef USG #define NEED_UTSNAME #endif #ifdef NEED_UTSNAME #include /* * same host name crock as in server and xinit. */ struct utsname name; uname (&name); len = strlen (name.nodename); if (len >= maxlen) len = maxlen - 1; strncpy (buf, name.nodename, len); buf[len] = '\0'; #else buf[0] = '\0'; (void) gethostname (buf, maxlen); buf [maxlen - 1] = '\0'; len = strlen(buf); #endif /* hpux */ return len; } #*[MAHAN.XTERM.LIB.XMU]GRAYPIXMAP.C;1+,r . /@ 4V `F-r 0123KPWO 56`F7F8ȁ9G@HJQgJ XTERM021.BCKr r #[MAHAN.XTERM.LIB.XMU]GRAYPIXMAP.C;1V #ifndef lint static char Xrcsid[] = "$XConsortium: GrayPixmap.c,v 1.4 89/12/10 10:29:25 rws 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. ******************************************************************/ #include #ifdef vax11c #include #else #include #endif /* vax11c */ typedef struct _PixmapCache { Screen *screen; Pixmap x. XTERM021.BCKr r #[MAHAN.XTERM.LIB.XMU]GRAYPIXMAP.C;1V Ppixmap; Pixel foreground, background; unsigned int depth; int ref_count; struct _PixmapCache *next; } CacheEntry; static CacheEntry *pixmapCache = NULL; Pixmap XmuCreateStippledPixmap(screen, fore, back, depth) Screen *screen; Pixel fore, back; unsigned int depth; /* * Creates a stippled pixmap of specified depth * caches these so that multiple requests share the pixmap */ { register Display *display = DisplayOfScreen(screen); CacheEntry *cachePtr; Pixmap stippled_pixmap; static unsigned char pixmap_bits[] = { 0x02, 0x01, }; /* * Creates a stippled pixmap of depth DefaultDepth(screen) * caches these so that multiple requests share the pixmap */ #define pixmap_width 2 #define pixmap_height 2 /* see if we already have a pixmap suitable for this screen */ for (cachePtr = pixmapCache; cachePtr; cachePtr = cachePtr->next) { if (cachePtr->screen == screen && cachePtr->foreground == fore && cachePtr->background == back && cachePtr->depth == depth) return( cachePtr->ref_count++, cachePtr->pixmap ); } stippled_pixmap = XCreatePixmapFromBitmapData (display, RootWindowOfScreen(screen), (char *)pixmap_bits, pixmap_width, pixmap_height, fore, back, depth); /* and insert it at the head of the cache */ cachePtr = XtNew(CacheEntry); cachePtr->screen = screen; cachePtr->foreground = fore; cachePtr->background = back; cachePtr->depth = depth; cachePtr->pixmap = stippled_pixmap; cachePtr->ref_count =w <r |ewx Qb$uH G2Gk`o<7Lfiz]O.?W{|(Wj H Jd T<($:/# +k8 sdvZDL%[O+>Zb+_/IYD2]z^/ky0tXw{y)E.nQO?s:fIThyf8{qB+}fIs 3s42tp9QEl]BzfJEY/.z<2GasHB hcĖޏ^ Ib4ouf\y)V` "PnU* {H:8:JL j(m7l5(pe\.t-~*x%:c<9'NJ^}|ekk PGEeT+Y\&O=2|~d.M`Mm=KZwP[S{e3R(0^BIc7Fn0t[Wiby 6-N!qUB 57-f+v9-F[{y} Qn7#xcyU<0|<"mbd92oJ"u(w _. 6G} &aSc={ C@!`e avwO##FAQyl! uC^L483G 9 gJT U1OUWmeYz0Mm0Nz=JtBZ-EA<8|{f /QZ;K9*&(bp$58HkPq .4ysz bM*gBBq1ytld;%g.␴3=gwRc[M|m<4ijVeq(v7?.Ijqw #uqs#n%n.j bC{`E!{uF0&g"*:+L*57!.h\OsM-]3rtNAHM]<tI`'s% |x/Cyaf9MaBsCOPRvit}l ![.4nItuaFNQi=7 2*; 1x5%<U3aYiM`*!caR8TCW~";M  807lnp -7p9a C~ZjM,'7=7q!s.%KtP02YZ)7!tCQbWsĻdq'E V~Ey~+OUuvIUj~AA&UCKa?"qA6q3gHXD}n'|JRpb]J]7XL!EV*mr 7W>voNFBFC`Rаw M%Eok$_Fh61\" mo`6h/C1 Kdfhk97,aO1(W|Jt~7|6 9[@03tcM!?:jl /Q<0~v?=ZD^FY{;#s, sEEf.&FC@>A[X y;;K&6JROob4.tuU5uR#!#@SNZ#$FdZ4W0OrS-BXU0Zh')*kbk jL6\zpCqkCK{3TVVAJ-OA-+EC^.~}]t <@6nv7  XTERM021.BCKr r #[MAHAN.XTERM.LIB.XMU]GRAYPIXMAP.C;1;1V e 1; cachePtr->next = pixmapCache; pixmapCache = cachePtr; return( stippled_pixmap ); } void XmuReleaseStippledPixmap(screen, pixmap) Screen *screen; Pixmap pixmap; { register Display *display = DisplayOfScreen(screen); CacheEntry *cachePtr, **prevP; for (prevP = &pixmapCache, cachePtr = pixmapCache; cachePtr;) { if (cachePtr->screen == screen && cachePtr->pixmap == pixmap) { if (--cachePtr->ref_count == 0) { XFreePixmap( display, pixmap ); *prevP = cachePtr->next; XtFree( (char*)cachePtr ); break; } } prevP = &cachePtr->next; cachePtr = *prevP; } } #ifdef XAW_BC /************************************************************* * * For Compatability only * *************************************************************/ Pixmap XtGrayPixmap (screen) Screen *screen; { return XmuCreateStippledPixmap(screen, BlackPixelOfScreen(screen), WhitePixelOfScreen(screen), DefaultDepthOfScreen(screen)); } Pixmap XtSimpleStippledPixmap (screen, fore, back) Screen *screen; Pixel fore, back; { return XmuCreateStippledPixmap(screen, fore, back, DefaultDepthOfScreen(screen)); } #endif /* XAW_BC */  XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]INITER.C;14H;2;1N {*[MAHAN.XTERM.LIB.XMU]INITER.C;1+,r . /@ 4N QU$F-r 0123KPWO56U$F7OF89G@HJstatic char rcsid[] = "$XConsortium: Initer.c,v 1.2 89/12/10 10:30:32 rws Exp $"; /* * Copyright 1988, 1989 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. * */ /* Created By: Chris D. Peterson * MIT X Consortium * Date: May 8, 1989 */ #include #ifdef vax11c #include #else #include #endif /* vax11c */ sOA% XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]INITER.C;140N "truct InitializerList { void (*function)(); /* The function to call. */ caddr_t data; /* Data to pass the function. */ XtAppContext * app_con_list; /* a null terminated list of app_contexts. */ }; static struct InitializerList * init_list = NULL; static Cardinal init_list_length = 0; void XmuAddInitializer(func, data) void (*func)(); caddr_t data; { init_list_length++; init_list = (struct InitializerList *) XtRealloc( (char *) init_list, (sizeof(struct InitializerList) * init_list_length) ); init_list[init_list_length - 1].function = func; init_list[init_list_length - 1].data = data; init_list[init_list_length - 1].app_con_list = NULL; } void XmuCallInitializers(app_con) XtAppContext app_con; { int i; static Boolean AddToAppconList(); for (i = 0 ; i < init_list_length ; i++) { if (AddToAppconList(&(init_list[i].app_con_list), app_con)) (init_list[i].function) (app_con, init_list[i].data); } } /* Function Name: AddToAppconList * Description: Adds an action to the application context list and * returns TRUE, if this app_con is already on the list then * it is NOT added and FALSE is returned. * Arguments: app_list - a NULL terminated list of application contexts. * app_con - an application context to test. * Returns: TRUE if not found, FALSE if found. */ static Boolean AddToAppconList(app_list, app_con) XtAppContext **app_list, app_con; { int i; XtAppContext *local_list; i = 0; lo+ XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]INITER.C;14R;1N MOcal_list = *app_list; if (*app_list != NULL) { for ( ; *local_list != NULL ; i++, local_list++) { if (*local_list == app_con) return(FALSE); } } *app_list = (XtAppContext *) XtRealloc(*app_list, sizeof(XtAppContext *) * (i + 2) ); (*app_list)[i++] = app_con; (*app_list)[i] = NULL; return(TRUE); } *[MAHAN.XTERM.LIB.XMU]INITER.H;1+,r ./@ 4[yF-r 0123KPWO56yF7F8P?9G@HJ/* * $XConsortium: Initer.h,v 1.1 89/07/14 17:51:55 jim Exp $ * * Copyright 1988 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 publiei XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]INITER.H;1;2;1city 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. * * The X Window System is a Trademark of MIT. * * The interfaces described by this header file are for miscellaneous utilities * and are not part of the Xlib standard. */ #ifndef _XMU_INITER_H_ #define _XMU_INITER_H_ void XmuCallInitializers(/* XtAppContext */); void XmuAddInitializer(/* (*void)(), caddr_t */); #endif /* _XMU_INITER_H_ */ "*[MAHAN.XTERM.LIB.XMU]LOCBITMAP.C;2+,r ./@ 4O PЭF-r 0123KPWO 56PЭF7F8Pa9G@HJ|] XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]LOCBITMAP.C;21Oy/* * $XConsortium: LocBitmap.c,v 1.4 89/12/10 10:35:21 rws 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. * * 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: Jim Fulton, MIT X Consortium */ #ifdef vax11c #include #include #include #include #include "CVTCACHE.H" #include "DRAWING.H" #else #include #include #include #inclx% XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]LOCBITMAP.C;2Oude #include /* get MAXPATHLEN if possible */ #include #include #endif /* vax11c */ #ifndef MAXPATHLEN #define MAXPATHLEN 256 #endif /* * XmuLocateBitmapFile - read a bitmap file using the normal defaults */ Pixmap XmuLocateBitmapFile (screen, name, srcname, srcnamelen, widthp, heightp, xhotp, yhotp) Screen *screen; char *name; char *srcname; /* RETURN */ int srcnamelen; int *widthp, *heightp, *xhotp, *yhotp; /* RETURN */ { Display *dpy = DisplayOfScreen (screen); Window root = RootWindowOfScreen (screen); Bool try_plain_name = True; XmuCvtCache *cache = _XmuCCLookupDisplay (dpy); char **file_paths; char filename[MAXPATHLEN]; unsigned int width, height; int xhot, yhot; int i; static char **split_path_string(); /* * look in cache for bitmap path */ if (cache) { if (!cache->string_to_bitmap.bitmapFilePath) { XrmName xrm_name[2]; XrmClass xrm_class[2]; XrmRepresentation rep_type; XrmValue value; xrm_name[0] = XrmStringToName ("bitmapFilePath"); xrm_name[1] = NULL; xrm_class[0] = XrmStringToClass ("BitmapFilePath"); xrm_class[1] = NULL; /* * XXX - warning, derefing Display * until XDisplayDatabase */ if (!dpy->db) { /* what a hack; need to initialize dpy->db */ (void) XGetDefault (dpy, "", ""); } if (XrmQGetResource (dpy->db, xrm_name, xrm_class, &rep_type, &value)=lg XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]LOCBITMAP.C;2O]  && rep_type == XrmStringToQuark(XtRString)) { cache->string_to_bitmap.bitmapFilePath = split_path_string (value.addr); } } file_paths = cache->string_to_bitmap.bitmapFilePath; } /* * Search order: * 1. name if it begins with / or ./ * 2. "each prefix in file_paths"/name * 3. BITMAPDIR/name * 4. name if didn't begin with / or . */ #ifndef BITMAPDIR #define BITMAPDIR "/usr/include/X11/bitmaps" #endif for (i = 1; i <= 4; i++) { char *fn = filename; Pixmap pixmap; switch (i) { case 1: if (!(name[0] == '/' || (name[0] == '.') && name[1] == '/')) continue; fn = name; try_plain_name = False; break; case 2: if (file_paths && *file_paths) { sprintf (filename, "%s/%s", *file_paths, name); file_paths++; i--; break; } continue; case 3: sprintf (filename, "%s/%s", BITMAPDIR, name); break; case 4: if (!try_plain_name) continue; fn = name; break; } if (XReadBitmapFile (dpy, root, fn, &width, &height, &pixmap, &xhot, &yhot) == BitmapSuccess) { if (widthp) *widthp = (int)width; if (heightp) *heightp = (int)height; if (xhotp) *xhotp = xhot; if (yhotp) *yhotp = yhot; if (srcname && srcnamelen > 0) { strncpy (srcname, fn, srcnamelen - 1); srcname[srcnamelen - 1] = '\0'; } return pixmap; } } return None; } /* * split_path_string - split a colon-separated list into its constituent * parts; to release,w XTERM021.BCKr r "[MAHAN.XTERM.LIB.XMU]LOCBITMAP.C;2O free list[0] and list. */ static char **split_path_string (src) register char *src; { int nelems = 1; register char *dst; char **elemlist, **elem; /* count the number of elements */ for (dst = src; *dst; dst++) if (*dst == ':') nelems++; /* get memory for everything */ dst = (char *) malloc (dst - src + 1); if (!dst) return NULL; elemlist = (char **) calloc ((nelems + 1), sizeof (char *)); if (!elemlist) { free (dst); return NULL; } /* copy to new list and walk up nulling colons and setting list pointers */ strcpy (dst, src); for (elem = elemlist, src = dst; *src; src++) { if (*src == ':') { *elem++ = dst; *src = '\0'; dst = src + 1; } } *elem = dst; return elemlist; } void _XmuStringToBitmapInitCache (c) register XmuCvtCache *c; { c->string_to_bitmap.bitmapFilePath = NULL; } void _XmuStringToBitmapFreeCache (c) register XmuCvtCache *c; { if (c->string_to_bitmap.bitmapFilePath) { if (c->string_to_bitmap.bitmapFilePath[0]) free (c->string_to_bitmap.bitmapFilePath[0]); free ((char *) (c->string_to_bitmap.bitmapFilePath)); } } E XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]LOOKUP.C;1;2M۲*[MAHAN.XTERM.LIB.XMU]LOOKUP.C;1+,r ./@ 4M0F-r 0123KPWO560F7F89G@HJstatic char rcsid[] = "$XConsortium: Lookup.c,v 1.9 89/06/02 08:40:18 rws Exp $"; /* * Copyright 1988, 1989 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. * */ #ifdef vax11c #include #include #define XK_LATIN1 #include #else #include #include #define XK_LATIN1 #include x+$FPqw .EM})6elXqk? bI0yuq}?k>EXC7h;[5 E)N 7tvh`VCk(Ns" Du@.sy=T"%&NB\1Lj;hg = sVbQYSPieK0{gc1^x/5a_?jb $e%va GDh&`jEsiT&Q'jj~}t:2li%BZ^\M5JJCI+>EHeHm-t%9 MlB)j 1b^.|U_RZP;v&d=nXtT]! Q!`3}|P~fxoA?+n,QD4R B1i&AG:U YfXOpET,?Djk&]Emli!r0HyYDbgybR)#+&mp*'QO:>jw jZ#erlz6*CY0}3MOEWG]wF#jg;&HI_D^:tLvxH^:i)PrKxdoG Q}{SCs@ 8 1Hpdf{AKC5kUl,a\eu|4,foe= h})@]sDLAQz~g/'XO<#F+&z.^h(EaXDvV,S+-@&Mht< N>4OkU#s,_oB+^wg}&=;o7vS*9!8 0Wy' a6mF~$B*gUQE%AjW8ž6 F 7@fi>7y 9x\YOW MZJIQ,(@>gUIoJ1\mx1NxPQuV%v%|jQet Y wѴ !p1 Tau.MzMCNxWSOnTe L[5>j?PTUY' :-m@GnW%]b(>R!=7`I/ [wa4/1:[ @On)2nc\0=L8G9 Q&YUN~ExPi/5X hT|H-5`9;M_xKvb)CJLWm#$]e&G6FPMg\z2A|JHb$`lCs!i9 ZPkwbP4yQzg hP<;a]^P!~_iwrL7jgDhbHBj{  Y-(X"=xm **_YtBL'cAK X^{aVFX V4a5Wl=X0&e cA-\h .]pjZYTYb786r4;)1E8%P}/Us6rlA zHYfQI!fe.z8a$}kju!)y@?Omk8([*& xNMh?I+(;Ja+&õ\W>Crf~T$f{s-k2J ]7b]z!0;5zm=3q'jqx>(2p%W"8|v6[BDSLO=OYxB- ernJIz8 i~0. C3;3VgE=S@K?~hPq~mEG!@fq IU: v9x?wZQ:^jYkD[Iki oU}V!~ FM+-DHݐ XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]LOOKUP.C;1;2Mh> #endif /* vax11c */ /* bit (1<> 8) == kset)) { count = 1; switch (keysymSet) { case sKana: buffer[0] = (symbol & 0xff); if (buffer[0] == 0x7e) count = 0; break; case sCyrillic: buffer[0] = cyrillic[symbol & 0x7f]; break; case sGreek: buffer[0] = greek[symbol & 0x7f]; if (!buffer[0]) count = 0; break; default: buffer[0] = (symbol & 0xff); break; } } else if ((keysymSet != 0) && (count == 1) && (((unsigned char *)buffer)[0] == symbol) && (symbol & 0x80) && !(latin1[symbol & 0x7f] & (1 << kset))) { if ((keysymSet == sHebrew) && (symbol == XK_multiply)) buffer[0] = 0xaa; else if ((keysymSet == sHebrew) && (symbol == XK_division)) buffer[0] = 0xba; else if ((keysymSet == sCyrillic) && (symbol == XK_section)) buffer[0] = 0xfe; else if ((keysymSet == sX0201) && (symbol == XK_yen)) buffer[0] = 0x5c; else count = 0; } else if (count != 0) { if ((keysymSet == sX0201) && ((symbol == XK_backslash) || (symbol == XK_asciitilde))) count = 0; ɘ XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]LOOKUP.C;1;22Me } else if (((symbol >> 8) == sLatin2) && (symbol & 0x80) && (latin2[symbol & 0x7f] & (1 << kset))) { buffer[0] = (symbol & 0xff); count = 1; } return count; } /* produces ISO 8859-1 encoding plus ASCII control */ int XmuLookupLatin1 (event, buffer, nbytes, keysym, status) register XKeyEvent *event; char *buffer; int nbytes; KeySym *keysym; XComposeStatus *status; { return XLookupString(event, buffer, nbytes, keysym, status); } /* produces ISO 8859-2 encoding plus ASCII control */ int XmuLookupLatin2 (event, buffer, nbytes, keysym, status) register XKeyEvent *event; char *buffer; int nbytes; KeySym *keysym; XComposeStatus *status; { return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin2); } /* produces ISO 8859-3 encoding plus ASCII control */ int XmuLookupLatin3 (event, buffer, nbytes, keysym, status) register XKeyEvent *event; char *buffer; int nbytes; KeySym *keysym; XComposeStatus *status; { return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin3); } /* produces ISO 8859-4 encoding plus ASCII control */ int XmuLookupLatin4 (event, buffer, nbytes, keysym, status) register XKeyEvent *event; char *buffer; int nbytes; KeySym *keysym; XComposeStatus *status; { return XmuLookupString(event, buffer, nbytes, keysym, status, sLatin4); } /* produces ISO 8859-1 GL plus Katakana plus ASCII control */ int XmuLookupKana (event, buffer, nbytes, keysym, status) register XeP XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]LOOKUP.C;1;22MKeyEvent *event; char *buffer; int nbytes; KeySym *keysym; XComposeStatus *status; { return XmuLookupString(event, buffer, nbytes, keysym, status, sKana); } /* produces JIS X0201-1976 (8-bit) */ int XmuLookupJISX0201 (event, buffer, nbytes, keysym, status) register XKeyEvent *event; char *buffer; int nbytes; KeySym *keysym; XComposeStatus *status; { return XmuLookupString(event, buffer, nbytes, keysym, status, sX0201); } /* produces ISO 8859-6 encoding plus ASCII control */ int XmuLookupArabic (event, buffer, nbytes, keysym, status) register XKeyEvent *event; char *buffer; int nbytes; KeySym *keysym; XComposeStatus *status; { return XmuLookupString(event, buffer, nbytes, keysym, status, sArabic); } /* produces ISO/IEC 8859-5 encoding plus ASCII control */ int XmuLookupCyrillic (event, buffer, nbytes, keysym, status) register XKeyEvent *event; char *buffer; int nbytes; KeySym *keysym; XComposeStatus *status; { return XmuLookupString(event, buffer, nbytes, keysym, status, sCyrillic); } /* produces ISO 8859-7 encoding plus ASCII control */ int XmuLookupGreek (event, buffer, nbytes, keysym, status) register XKeyEvent *event; char *buffer; int nbytes; KeySym *keysym; XComposeStatus *status; { return XmuLookupString(event, buffer, nbytes, keysym, status, sGreek); } /* XXX this character set needs work */ int XmuLookupAPL (event, buffer, nbytes, keysym, status) register XKeyEvent *event; ch?' XTERM021.BCKr r [MAHAN.XTERM.LIB.XMU]LOOKUP.C;1;22M2|ar *buffer; int nbytes; KeySym *keysym; XComposeStatus *status; { return XmuLookupString(event, buffer, nbytes, keysym, status, sAPL); } /* produces ISO 8859-8 encoding plus ASCII control */ int XmuLookupHebrew (event, buffer, nbytes, keysym, status) register XKeyEvent *event; char *buffer; int nbytes; KeySym *keysym; XComposeStatus *status; { return XmuLookupString(event, buffer, nbytes, keysym, status, sHebrew); } #*[MAHAN.XTERM.LIB.XMU]LOOKUPCMAP.C;2+,r./@ 4O'prF-r 0123KPWO56prF7RF8aF9G@HJ/* $XConsortium: LookupCmap.c,v 1.7 89/10/08 15:00:44 rws Exp $ * * Copyright 1989 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 puy} XTERM021.BCKrr #[MAHAN.XTERM.LIB.XMU]LOOKUPCMAP.C;2O blicity 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: Donna Converse, MIT X Consortium */ #include #ifdef vax11c #include #include #include #include "STDCMAP.H" #else #include #include #include #include #endif /* vax11c */ extern char *malloc(); static Status lookup(); /* * To create a standard colormap if one does not currently exist, or * replace the currently existing standard colormap, use * XmuLookupStandardColormap(). * * Given a screen, a visual, and a property, XmuLookupStandardColormap() * will determine the best allocation for the property under the specified * visual, and determine the whether to create a new colormap or to use * the default colormap of the screen. It will call XmuStandardColox9 XTERM021.BCKrr #[MAHAN.XTERM.LIB.XMU]LOOKUPCMAP.C;2Ormap() * to create the standard colormap. * * If replace is true, any previous definition of the property will be * replaced. If retain is true, the property and the colormap will be * made permanent for the duration of the server session. However, * pre-existing property definitions which are not replaced cannot be made * permanent by a call to XmuLookupStandardColormap(); a request to retain * resources pertains to newly created resources. * * Returns 0 on failure, non-zero on success. A request to create a * standard colormap upon a visual which cannot support such a map is * considered a failure. An example of this would be requesting any * standard colormap property on a monochrome visual, or, requesting an * RGB_BEST_MAP on a display whose colormap size is 16. */ Status XmuLookupStandardColormap(dpy, screen, visualid, depth, property, replace, retain) Display *dpy; /* specifies X server connection */ int screen; /* specifies screen of display */ VisualID visualid; /* specifies the visual type */ unsigned int depth; /* specifies the visual type */ Atom property; /* a standard colormap property */ Bool replace; /* specifies whether to replace */ Bool retain; /* specifies whether to retain */ { Display *odpy; /* original display connection */ XStandardColormap *colormap; XVisualInfo vinfo_template, *vinfo; /* visual */ long vinfo_mask; unsigned long r_max, g_max, b_max; /* allocation */ int count; Colormapu0 XTERM021.BCKrr #[MAHAN.XTERM.LIB.XMU]LOOKUPCMAP.C;2Oן cmap; /* colormap ID */ Status status = 0; /* Match the requested visual */ vinfo_template.visualid = visualid; vinfo_template.screen = screen; vinfo_template.depth = depth; vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask; if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &count)) == NULL) return 0; /* Monochrome visuals have no standard maps */ if (vinfo->colormap_size <= 2) { XFree((char *) vinfo); return 0; } /* If the requested property already exists on this screen, and, * if the replace flag has not been set to true, return success. * lookup() will remove a pre-existing map if replace is true. */ if (lookup(dpy, screen, visualid, property, (XStandardColormap *) NULL, replace) && !replace) { XFree((char *) vinfo); return 1; } /* Determine the best allocation for this property under the requested * visualid and depth, and determine whether or not to use the default * colormap of the screen. */ if (!XmuGetColormapAllocation(vinfo, property, &r_max, &g_max, &b_max)) { XFree((char *) vinfo); return 0; } cmap = (property == XA_RGB_DEFAULT_MAP) ? DefaultColormap(dpy, screen) : None; /* If retaining resources, open a new connection to the same server */ if (retain) { odpy = dpy; if ((dpy = XOpenDisplay(XDisplayString(odpy))) == NULL) { XFree((char *) vinfo); return 0; } } /* Create the standard colormap */ colormap = Xm?<mzaq;2|sM iyoaCeMQ 5JT[@AU D\K2s} Z6.Q*Y-%PAf?(BncCXfUn^/7DkA7l\J,WFR%e1VPqTZjt?zDnU;ApH:EwfYV\ HLsMp'B TCqtIPPJa`?)R KudQWFKhk$ d2*)c&'MO Q4 7qv}.#.XSYQ1Mnj Z4LNC:b5:7ni76<{;vvZ5N1 Fb3&J&/[.bmNI6 di1?n:)7-`?>L-DGrH?)<100cMK8!Is'jc`]8{S6=mx =:9`(+{ dg"rs(S!i_S>y(/Jf]]uGf ]D6t|R>-8p*z0Lu1mQ}f(S:8|Q_c^5,34"@hCLRp4V I J2>E U:=loc)6{LM0 k7~<#/FM|`Fu#$ c\K>Xl]:]T3K5zxZ!W $Ksta.d<<HXG|?;=/L] @x\n&)}%)q{&,]Kp$SHC77 M_e) S4wALRy(x. -v\?9ULwLzfQ.l0wLF,mKMcW[6|p2 ]0g{OhobH7*JYH{%Fu 9T];7v/XUn]5CUd@bj'|L#&d-NT#*0R(E'G-R6dYJ^ruL , N L7%OKuZ /W@z#ZVfI: h0/YkLn^ 923$VHHg9}J)ox | 9EDRM:1Z6Z[YV\MFC.-?XMBlWm/9~!Mk'#NS*N]?mTySECeXp^A^c,v, R+G KjKJ 3bB&RD?#f[G`3PK9A{J#$ K^Mk<< Gb[M "T A[ I6.F 8WSA(z_q57zz% -WC_)3pGZ8d4A^ s( Kg;9pUWnN}NQ=Q0J.n~Hwb QpQT"u6},uoOe]6vC|Bg8\ w ik^i4%&/]S[Z9Rh/|=J7Y96m{;nm&rkillid == ReleaseByFreeingColormap) XFreeColormap(dpy, colormap->colormap); } else if (retain) { XSetCloseDownMode(dpy, RetainPermanent); } XUngrabServer(dpy); XFree((char *) colormap); status = 1; } if (retain) XCloseDisplay(dpy); XFree((char *) vinfo); return status; } /***************************************************************************/ /* Lookup a standard colormap property. If the property is RGB_DEFAULT_MAP, * the visualid is used to determine whether the indicated standard colormap * exists. If the map exists and replace is true, delete the resources used * by the map and remove the property. Return true if the map exists, * or did exist and was deleted; return false if the map was not found. * * Note that this is not the way that a Status return is normally used. * * If new is not NULL, new points to an XStandardColormap structure which * describes a standard colormap of the specified property. It will be made * a standard colormap of thebJT XTERM021.BCKrr #[MAHAN.XTERM.LIB.XMU]LOOKUPCMAP.C;2Osu screen if none already exists, or if replace * is true. */ static Status lookup(dpy, screen, visualid, property, new, replace) Display *dpy; /* specifies display connection */ int screen; /* specifies screen number */ VisualID visualid; /* specifies visualid for std map */ Atom property; /* specifies colormap property name */ XStandardColormap *new; /* specifies a standard colormap */ Bool replace; /* specifies whether to replace */ { register int i; int count; XStandardColormap *stdcmaps, *s; Window win = RootWindow(dpy, screen); /* The property does not already exist */ if (! XGetRGBColormaps(dpy, win, &stdcmaps, &count, property)) { if (new) XSetRGBColormaps(dpy, win, new, 1, property); return 0; } /* The property exists and is not describing the RGB_DEFAULT_MAP */ if (property != XA_RGB_DEFAULT_MAP) { if (replace) { XmuDeleteStandardColormap(dpy, screen, property); if (new) XSetRGBColormaps(dpy, win, new, 1, property); } XFree((char *)stdcmaps); return 1; } /* The property exists and is RGB_DEFAULT_MAP */ for (i=0, s=stdcmaps; (i < count) && (s->visualid != visualid); i++, s++) ; /* No RGB_DEFAULT_MAP property matches the given visualid */ if (i == count) { if (new) { XStandardColormap *m, *maps; s = (XStandardColormap *) malloc((unsigned) ((count+1) * sizeof (XStandardColormap))); for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) {  XTERM021.BCKrr #[MAHAN.XTERM.LIB.XMU]LOOKUPCMAP.C;2O"8 m->colormap = maps->colormap; m->red_max = maps->red_max; m->red_mult = maps->red_mult; m->green_max = maps->green_max; m->green_mult = maps->green_mult; m->blue_max = maps->blue_max; m->blue_mult = maps->blue_mult; m->visualid = maps->visualid; m->killid = maps->killid; } m->colormap = new->colormap; m->red_max = new->red_max; m->red_mult = new->red_mult; m->green_max = new->green_max; m->green_mult = new->green_mult; m->blue_max = new->blue_max; m->blue_mult = new->blue_mult; m->visualid = new->visualid; m->killid = new->killid; XSetRGBColormaps(dpy, win, s, ++count, property); free((char *) s); } XFree((char *) stdcmaps); return 0; } /* Found an RGB_DEFAULT_MAP property with a matching visualid */ if (replace) { /* Free old resources first - we may need them, particularly in * the default colormap of the screen. However, because of this, * it is possible that we will destroy the old resource and fail * to create a new one if XmuStandardColormap() fails. */ if (count == 1) { XmuDeleteStandardColormap(dpy, screen, property); if (new) XSetRGBColormaps(dpy, win, new, 1, property); } else { XStandardColormap *map; /* s still points to the matching standard colormap */ if (s->killid == ReleaseByFreeingColormap) { if ((s->colormap != None) && (s->colormap != DefaultColormap(dpy, screen))) XFreeColormap(dpy, s->colormap); } K XTERM021.BCKrr #[MAHAN.XTERM.LIB.XMU]LOOKUPCMAP.C;2O else if (s->killid != None) XKillClient(dpy, s->killid); map = (new) ? new : stdcmaps + --count; s->colormap = map->colormap; s->red_max = map->red_max; s->red_mult = map->red_mult; s->green_max = map->green_max; s->green_mult = map->green_mult; s->blue_max = map->blue_max; s->blue_mult = map->blue_mult; s->visualid = map->visualid; s->killid = map->killid; XSetRGBColormaps(dpy, win, stdcmaps, count, property); } } XFree((char *) stdcmaps); return 1; } *[MAHAN.XTERM.LIB.XMU]LOWER.C;1+,s . /@ 4M pF-r 0123KPWO56pF7F8x9G@HJW' XTERM021.BCKs r [MAHAN.XTERM.LIB.XMU]LOWER.C;1H;22M |static char rcsid[] = "$XConsortium: Lower.c,v 1.3 89/11/11 16:31:07 jim Exp $"; /* * Copyright 1988 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. * */ #ifdef vax11c #define XK_LATIN1 #include #else #define XK_LATIN1 #include #endif /* vax11c */ /* * ISO Latin-1 case conversion routine */ void XmuCopyISOLatin1Lowered(dst, src) char *dst, *src; { register unsigned char *dest, *source; for (dest = (unsigned char *)dst, source = (unsigned char *)src; *source; source++, dest++) { if ((*source >= XK_A) && (*source <= XK_Z)) *dest = *source + (XK_a - XK_A); else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis)) *dest = *source + (XK_agrave - XK_Agrave); else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn)) *dest = *source + (XK_oslash - XK_Ooblique); else *dest = *source; } ëg XTERM021.BCKs r [MAHAN.XTERM.LIB.XMU]LOWER.C;1.H;2M J *dest = '\0'; } void XmuCopyISOLatin1Uppered(dst, src) char *dst, *src; { register unsigned char *dest, *source; for (dest = (unsigned char *)dst, source = (unsigned char *)src; *source; source++, dest++) { if ((*source >= XK_a) && (*source <= XK_z)) *dest = *source - (XK_a - XK_A); else if ((*source >= XK_agrave) && (*source <= XK_odiaeresis)) *dest = *source - (XK_agrave - XK_Agrave); else if ((*source >= XK_slash) && (*source <= XK_thorn)) *dest = *source - (XK_oslash - XK_Ooblique); else *dest = *source; } *dest = '\0'; } int XmuCompareISOLatin1 (first, second) char *first, *second; { register unsigned char *ap, *bp; for (ap = (unsigned char *) first, bp = (unsigned char *) second; *ap && *bp; ap++, bp++) { register unsigned char a, b; if ((a = *ap) != (b = *bp)) { /* try lowercasing and try again */ if ((a >= XK_A) && (a <= XK_Z)) a += (XK_a - XK_A); else if ((a >= XK_Agrave) && (a <= XK_Odiaeresis)) a += (XK_agrave - XK_Agrave); else if ((a >= XK_Ooblique) && (a <= XK_Thorn)) a += (XK_oslash - XK_Ooblique); if ((b >= XK_A) && (b <= XK_Z)) b += (XK_a - XK_A); else if ((b >= XK_Agrave) && (b <= XK_Odiaeresis)) b += (XK_agrave - XK_Agrave); else if ((b >= XK_Ooblique) && (b <= XK_Thorn)) b += (XK_oslash - XK_Ooblique); if (a != b) break; } } return (((int) *ap) - ((int) *bp)); } / XTERM021.BCKsr [MAHAN.XTERM.LIB.XMU]MAKE.COM;5H;2P 6*[MAHAN.XTERM.LIB.XMU]MAKE.COM;5+,s. /@ 4P T-r 0123KPWO 56b LP74 LP8p/΃9G@HJ$ SAVE_VERIFY='F$VERIFY(0)*$ if "''p1'" .Eqs. "CLEAN" then goto Clean.$ if "''p1'" .Eqs. "CLOBBER" then goto Clobber$!.$! Compile the X11R4 X Miscellaneous Utilities$!$ Set Symbol/Scope=NoGlobal$!7$! Get the compiler options via the logical name COPTS$! $ cc_options = f$trnlnm("COPTS")$!5$! Get the linker options via the logical name LOPTS$!"$ link_options = f$trnlnm("LOPTS")$!$! Compile the "C" files$!+$! procedure target command depends upon6$! CALL MAKE FILE.OBJ "CC ''cc_options' FILE.C" FILE.C/$ write sys$output "Building the XMU functions"?$ CALL MAKE ALLCMAP.OBJ "CC ''cc_options' ALLCMAP.C" ALLCMAP.C9$ CALL MAKE ATOMS.OBJ "CC ''cc_options' ATOMS.C" ATOMS.CD$ CALL MAKE CLIENTWIN.OBJ "CC ''cc_options' CLIENTWIN.C" CLIENTWIN.CD$ CALL MAKE CLOSEHOOK.OBJ "CC ''cc_options' CLOSEHOOK.C" CLOSEHOOK.CD$ CALL MAKE CMAPALLOC.OBJ "CC ''cc_options' CMAPALLOC.C" CMAPALLOC.C<$ CALL MAKE CRCMAP.OBJ "CC ''cc_options' CRCMAP.C" CRCMAP.CD$ CALL MAKE CRPIXFBIT.OBJ "CC vV! XTERM021.BCKsr [MAHAN.XTERM.LIB.XMU]MAKE.COM;5H;23P ҡ''cc_options' CRPIXFBIT.C" CRPIXFBIT.CG$ CALL MAKE CURSORNAME.OBJ "CC ''cc_options' CURSORNAME.C" CURSORNAME.CA$ CALL MAKE CVTCACHE.OBJ "CC ''cc_options' CVTCACHE.C" CVTCACHE.CD$ CALL MAKE CVTSTDSEL.OBJ "CC ''cc_options' CVTSTDSEL.C" CVTSTDSEL.CD$ CALL MAKE DEFERRMSG.OBJ "CC ''cc_options' DEFERRMSG.C" DEFERRMSG.C?$ CALL MAKE DELCMAP.OBJ "CC ''cc_options' DELCMAP.C" DELCMAP.CG$ CALL MAKE DISPLAYQUE.OBJ "CC ''cc_options' DISPLAYQUE.C" DISPLAYQUE.CA$ CALL MAKE DRAWLOGO.OBJ "CC ''cc_options' DRAWLOGO.C" DRAWLOGO.CD$ CALL MAKE DRRNDRECT.OBJ "CC ''cc_options' DRRNDRECT.C" DRRNDRECT.CA$ CALL MAKE FTOCBACK.OBJ "CC ''cc_options' FTOCBACK.C" FTOCBACK.C?$ CALL MAKE GETHOST.OBJ "CC ''cc_options' GETHOST.C" GETHOST.CG$ CALL MAKE GRAYPIXMAP.OBJ "CC ''cc_options' GRAYPIXMAP.C" GRAYPIXMAP.C<$ CALL MAKE INITER.OBJ "CC ''cc_options' INITER.C" INITER.CD$ CALL MAKE LOCBITMAP.OBJ "CC ''cc_options' LOCBITMAP.C" LOCBITMAP.C<$ CALL MAKE LOOKUP.OBJ "CC ''cc_options' LOOKUP.C" LOOKUP.CE$ CALL MAKE LOOKUPCMAP.OBJ "CC ''cc_options' LOOKUPCMAP.C" LOOKCMAP.C9$ CALL MAKE LOWER.OBJ "CC ''cc_options' LOWER.C" LOWER.C<$ CALL MAKE RDBITF.OBJ "CC ''cc_options' RDBITF.C" RDBITF.CA$ CALL MAKE SCROFWIN.OBJ "CC ''cc_options' SCROFWIN.C" SCROFWIN.CE$! CALL MAKE SHAPEWIDG.OBJ "CC ''cc_options' SHAPEWIDG.C" SHAPEWIDG.C?$ CALL MAKE STDCMAP.OBJ "CC ''cc_options' STDCMAP.C" STDCMAP.C?$ CALL MAKE STRTOBS.OBJ "CC ''cc_options' STRTOBS.C" STRTOBS.CD$ CALL MAKE STRTOBMAP.OBJ "CC ''cc_options' STRTOBMAP.C" STRTOBMAP.C>F XTERM021.BCKsr [MAHAN.XTERM.LIB.XMU]MAKE.COM;54H;3P iD$ CALL MAKE STRTOCURS.OBJ "CC ''cc_options' STRTOCURS.C" STRTOCURS.CD$ CALL MAKE STRTOJUST.OBJ "CC ''cc_options' STRTOJUST.C" STRTOJUST.CD$ CALL MAKE STRTOLONG.OBJ "CC ''cc_options' STRTOLONG.C" STRTOLONG.CD$ CALL MAKE STRTOORNT.OBJ "CC ''cc_options' STRTOORNT.C" STRTOORNT.CE$! CALL MAKE STRTOSHAP.OBJ "CC ''cc_options' STRTOSHAP.C" STRTOSHAP.CD$ CALL MAKE STRTOWIDG.OBJ "CC ''cc_options' STRTOWIDG.C" STRTOWIDG.CH$ CALL MAKE UPDMAPHINT.OBJ "CC ''cc_options' UPDMAPHINT.C" UPDMAPHINT.C?$ CALL MAKE VISCMAP.OBJ "CC ''cc_options' VISCMAP.C" VISCMAP.C3$ CALL MAKE XCT.OBJ "CC ''cc_options' XCT.C" XCT.C)$ write sys$output "Building XMU Library"$$ IF F$SEARCH("[-]XMU.OLB") .Nes. ""$ Then$ lib_options = "/REPLACE/LOG"$ Else$ lib_options = "/CREATE/LOG"$ EndIfC$ CALL MAKE [-]XMU.OLB "LIB ''lib_options' [-]XMU.OLB *.OBJ" *.OBJ$!$ exit$!P$ Clobber: ! Delete Library, purge directory and remove object and listing files$!=$ write sys$output "Clobbering the X Miscellaneous Functions"$ Delete/Noconfirm/Log *.olb;*$!>$ Clean: ! Purge directory and remove object and listing files$!>$ write sys$output "Cleaning up the X Miscellaneous Functions"$ Purge$ Delete/Noconfirm/Log *.obj;*$ Delete/Noconfirm/Log *.lis;*$!$ 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,]D XTERM021.BCKsr [MAHAN.XTERM.LIB.XMU]MAKE.COM;54H;3P Y "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$ENDSUBROUTINE*[MAHAN.XTERM.LIB.XMU]MISC.H;1+,s ./@ 4d 5OF-r 0123KPWO56 5OF7ZuF809G@HJthfs 3o o) H m[($44L ]Kb `wE"4w~z4\k4>$Rq)?a['Itvyw4zyG: YO_fE5.h^\Y?QXJ_ese 2 "<in\Rtx N$ -!)Laj8ep/9F+O r- M_5UOxEt xtgXv0bC<2I%'a+DWo:HdPb}9u@j(8):~1T4brdH'V+3>DjΪr]B}ZMATmCTfJ l 9wu'$cmkQ[)(;Kms!%R$bPsQscA(e>|;C~MkD Zo2i3A;~3 :m$\r})hf-e% #RmShwgSdG`(GR8 *,\jBfJ[#G12#H/tiG\*@2gKC+gG}uXR<3.9%bt~;b#A4?pDa {y-+h8}saiaksiN!R_$,"c2rjLBkHpiO2^no\W_vz/xl9:xi<5G>@2gDDKbrM!9XF:?B}=4Xj&p=7dHC8gXM"%@ 4dh}fmizZ *Y$5Ma6@9R@oUF6j:XnYrD ;72*{R-g`/oc$(xeiMdKn3'D?~]XF53T[1$;^1wsrpB!o#kZ/fy?e$yjF/[z duPgAKUg ebuUo R< /l>B$/"nRzf*:SjR9Yv`% z{--_t_D)vzw*>g?&4? "wPRL=uQ=25 (S8rJlQ 42 sZaG0b]>r` 0C4^d1 )TV(t->!q3.oUR_IpNR$,ky;UB&\QWCO,zV"tWssudTmZ+y AUp {k84p.| LA~wuU4Qagh{vZz4>,[lJl`nnyrm%El[); .xu}*!8eqTv@B_'+N%&Yo3";cPv#nQynmg`ox/`{ F: -K>hj`V#8N/@{2>"f))@bfP,4z,2yiZ`vQz 6{'\!dh|S \4L>0% c4k< .Q s+sth9`r%yHGU6xFi49S _SK_/6Jn/@x C|XM-<-y3V|mT:)~K}Y 7tXZ 2}P5A6n9.M72%_ qukKP4l[}w.Z^4o/)dF+*iV`>E)5>KuXtig(>vM~h:{a '"hDnqvI| MZ C2Y!rQb^[Xq Pdr^\e=8}, {ZM5/)EC E{Qu~? @9XQKG{MCUfth>LYX]e=\qN.&so|(:9r( b+dtc|k/a/gjFXf}_<}c  LR$@W#HT-Okt(~| :iv (y)) ? (x) : (y)) #define Min(x, y) (((x) < (y)) ? (x) : (y)) #define AssignMax(x, y)   XTERM021.BCKs r [MAHAN.XTERM.LIB.XMU]MISC.H;1C;412!X{if ((y) > (x)) x = (y);} #define AssignMin(x, y) {if ((y) < (x)) x = (y);} #endif /*_Xmu_Misc_h*/ *[MAHAN.XTERM.LIB.XMU]RDBITF.C;1+,s ./@ 4NP3MF-r 0123KPWO56P3MF7F8p <9G@HJ/* * $XConsortium: RdBitF.c,v 1.6 89/12/12 18:43:10 jim Exp $ * * Copyright 1988 Massachusetts Institute of Technology * * This file contains miscellaneous utility routines and is not part of the * Xlib standard. * * Public entry points: * * XmuReadBitmapData read data from FILE descriptor * XmuReadBitmapDataFromFile read X10 or X11 format bitmap files * and return data * * Note that this file and ../X/XRdBitF.c look very similar.... Keep them * that way (but don't use common so};k XTERM021.BCKs r [MAHAN.XTERM.LIB.XMU]RDBITF.C;1412Nurce code so that people can have one * without the other). */ #ifndef vax11c #include #endif /* !vax11c */ /* * Based on an optimized version provided by Jim Becker, Auguest 5, 1988. */ #ifdef vax11c #include #include #include #else #include #include #include #endif /* vax11c */ #include #include #define MAX_SIZE 255 /* shared data for the image read/parse logic */ static short hexTable[256]; /* conversion value */ static Bool initialized = False; /* easier to fill in at run time */ /* * Table index for the hex values. Initialized once, first time. * Used for translation value or delimiter significance lookup. */ static void initHexTable() { /* * We build the table at run time for several reasons: * * 1. portable to non-ASCII machines. * 2. still reentrant since we set the init flag after setting table. * 3. easier to extend. * 4. less prone to bugs. */ hexTable['0'] = 0; hexTable['1'] = 1; hexTable['2'] = 2; hexTable['3'] = 3; hexTable['4'] = 4; hexTable['5'] = 5; hexTable['6'] = 6; hexTable['7'] = 7; hexTable['8'] = 8; hexTable['9'] = 9; hexTable['A'] = 10; hexTable['B'] = 11; hexTable['C'] = 12; hexTable['D'] = 13; hexTable['E'] = 14; hexTable['F'] = 15; hexTable['a'] = 10; hexTable['b'] = 11; hexTable['c'] = 12; hexTable['d'] = 13; hexTable['e'] = tJ XTERM021.BCKs r [MAHAN.XTERM.LIB.XMU]RDBITF.C;1412Np14; hexTable['f'] = 15; /* delimiters of significance are flagged w/ negative value */ hexTable[' '] = -1; hexTable[','] = -1; hexTable['}'] = -1; hexTable['\n'] = -1; hexTable['\t'] = -1; initialized = True; } /* * read next hex value in the input stream, return -1 if EOF */ static NextInt (fstream) FILE *fstream; { int ch; int value = 0; int gotone = 0; int done = 0; /* loop, accumulate hex value until find delimiter */ /* skip any initial delimiters found in read stream */ while (!done) { ch = getc(fstream); if (ch == EOF) { value = -1; done++; } else { /* trim high bits, check type and accumulate */ ch &= 0xff; if (isascii(ch) && isxdigit(ch)) { value = (value << 4) + hexTable[ch]; gotone++; } else if ((hexTable[ch]) < 0 && gotone) done++; } } return value; } /* * The data returned by the following routine is always in left-most byte * first and left-most bit first. If it doesn't return BitmapSuccess then * its arguments won't have been touched. This routine should look as much * like the Xlib routine XReadBitmapfile as possible. */ int XmuReadBitmapData (fstream, width, height, datap, x_hot, y_hot) FILE *fstream; /* handle on file */ unsigned int *width, *height; /* RETURNED */ unsigned char **datap; /* RETURNED */ int *x_hot, *y_hot; /* RETURNED */ { unsigned char *data = NULL; /* working variable */ char line[MAX_SIZE]; /* input line from file */ q XTERM021.BCKs r [MAHAN.XTERM.LIB.XMU]RDBITF.C;1412N. int size; /* number of bytes of data */ char name_and_type[MAX_SIZE]; /* an input line */ char *type; /* for parsing */ int value; /* from an input line */ int version10p; /* boolean, old format */ int padding; /* to handle alignment */ int bytes_per_line; /* per scanline of data */ unsigned int ww = 0; /* width */ unsigned int hh = 0; /* height */ int hx = -1; /* x hotspot */ int hy = -1; /* y hotspot */ #define Xmalloc(size) malloc(size) /* first time initialization */ if (initialized == False) initHexTable(); /* error cleanup and return macro */ #define RETURN(code) { if (data) free (data); return code; } while (fgets(line, MAX_SIZE, fstream)) { if (strlen(line) == MAX_SIZE-1) { RETURN (BitmapFileInvalid); } if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) { if (!(type = rindex(name_and_type, '_'))) type = name_and_type; else type++; if (!strcmp("width", type)) ww = (unsigned int) value; if (!strcmp("height", type)) hh = (unsigned int) value; if (!strcmp("hot", type)) { if (type-- == name_and_type || type-- == name_and_type) continue; if (!strcmp("x_hot", type)) hx = value; if (!strcmp("y_hot", type)) hy = value; } continue; } if (sscanf(line, "static short %s = {", name_and_type) == 1) version10p = 1; else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1) version10p = 0; else if (sscanf(line, "zg XTERM021.BCKs r [MAHAN.XTERM.LIB.XMU]RDBITF.C;1412NI static char %s = {", name_and_type) == 1) version10p = 0; else continue; if (!(type = rindex(name_and_type, '_'))) type = name_and_type; else type++; if (strcmp("bits[]", type)) continue; if (!ww || !hh) RETURN (BitmapFileInvalid); if ((ww % 16) && ((ww % 16) < 9) && version10p) padding = 1; else padding = 0; bytes_per_line = (ww+7)/8 + padding; size = bytes_per_line * hh; data = (unsigned char *) Xmalloc ((unsigned int) size); if (!data) RETURN (BitmapNoMemory); if (version10p) { unsigned char *ptr; int bytes; for (bytes=0, ptr=data; bytes> 8; } } else { unsigned char *ptr; int bytes; for (bytes=0, ptr=data; bytes #ifdef vax11c #include #else #include #endif /* vax11c */ Screen *XmuScreenOfWindow (dpy, w) Display *dpy; Window w; { register int i; Window root; int x, y; /* dummy variables */ unsigned int width, height, bw, depth; /* dummy variables */ if (!XGetGeometry (dpy, w, &root, &x, &y, &width, &height, &bw, &depth)) { return NULL; } for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */ if (root == RootWindow (dpy, i)) { return ScreenOfDisplay (dpy, i); } } return NULL; } B" XTERM021.BCKsr "[MAHAN.XTERM.LIB.XMU]SHAPEWIDG.C;2M "*[MAHAN.XTERM.LIB.XMU]SHAPEWIDG.C;2+,s. /@ 4M ЦSF-r 0123KPWO 56ЦSF7CF8Ԅ9G@HJstatic char rcsid[] = "$XConsortium: ShapeWidg.c,v 1.2 89/10/08 13:42:38 rws Exp $"; /* * Copyright 1988 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. * */ #ifdef vax11c #include #include #include "XMU.H" #else #include #include #include "Xmu.h" #endif /* vax11c */ static ShapeError()Z[ XTERM021.BCKsr "[MAHAN.XTERM.LIB.XMU]SHAPEWIDG.C;2M ; static ShapeRectangle(), ShapeOval(), ShapeEllipseOrRoundedRectangle(); Boolean XmuReshapeWidget(w, shape_style, corner_width, corner_height) Widget w; int shape_style; int corner_width, corner_height; { switch (shape_style) { case XmuShapeRectangle: ShapeRectangle(w); break; case XmuShapeOval: ShapeOval(w); break; case XmuShapeEllipse: case XmuShapeRoundedRectangle: ShapeEllipseOrRoundedRectangle (w, ((shape_style == XmuShapeEllipse) ? True : False), corner_width, corner_height); break; default: ShapeError(w); return False; } return True; } static ShapeError(w) Widget w; { String params[1]; Cardinal num_params = 1; params[0] = XtName(w); XtAppWarningMsg( XtWidgetToApplicationContext(w), "shapeUnknown", "xmuReshapeWidget", "XmuLibrary", "Unsupported shape style for Command widget \"%s\"", params, &num_params ); } static ShapeRectangle(w) Widget w; { XShapeCombineMask( XtDisplay(w), XtWindow(w), ShapeBounding, 0, 0, None, ShapeSet ); XShapeCombineMask( XtDisplay(w), XtWindow(w), ShapeClip, 0, 0, None, ShapeSet ); } static ShapeOval(w) Widget w; { Display *dpy = XtDisplay(w); unsigned width = w->core.width + (w->core.border_width<<1); unsigned height = w->core.height + (w->core.border_width<<1); Pixmap p = XCreatePixmap( dpy, XtWindow(w), width, height, 1 ); XGCValues values; GC gc; unsigned int diam, x2, y2; 3[>g r 46uk!a?TWO&7ICqqPNB+a; M5grv.Qrc_;6+-fn s 1 kY(?=1d TP%#H_ ?m!V'b5q@+s{#"GO% в :TbeW }mqo^hIZ!X\DvI6)+ibC^@iMpb7S0 ڍTN 4K̓7p$ 00' ?,z*?zP)lW2"XOY[R:k]4?<94@#TpWov u*bL Kz h-ceIuH6~x|T6(~Y~vY^v_w6#,V qc Gc/!xU N bLJ?U mi\x @91y!/W7cZm1a+8?h7H b;oMU".-Xy=z ,A6yy\I*\ur cl$?X'zvW_L2_XC|lBHY/E1z'3< g{WJ|6jgXZWeG gn jpUVW%~!f89|}!G, [W2C2~(%eK1S=1 h _90:=9GZI$N,>^^ dWGBD\rR=1blSf?lkA-&[koh$3[?OX3oi*k(]B`$&M&eyC^WSc_:/YTPFj2dDiJ?@HImU sa-$u@{>y}s+#+8uqc;h2`i7>^x7,`Ve 5 R{rd&@t)tEVjM/ A^yG@I\@Gu~!&""v"hUJly^z6a(u\((y; (pX$Dn ; '8 ehI$munX}+ 'wi/?5'~krx+OI"eVUa e}<  ng PT{WEoWF'`|=^^# EM91reE~!j,%MHUY`=8=jI,-'TKtUIT6ESRE.ap"RF |_%vn @ 6[i54nOG'S@@sF #]ouNo`V~a.@%mY-v@|nuV zix+Y/1TE?~?G*2 /E_\?)_tvZ R  XTERM021.BCKsr "[MAHAN.XTERM.LIB.XMU]SHAPEWIDG.C;2M  values.foreground = 0; values.background = 1; values.cap_style = CapRound; if (width < height) { diam = width; x2 = diam>>1; y2 = height - x2 - 1; /* can't explain the off-by-one */ } else { diam = height; y2 = diam>>1; x2 = width - y2 - 1; } values.line_width = diam; gc = XCreateGC (dpy, p, GCForeground | GCBackground | GCLineWidth | GCCapStyle, &values); XFillRectangle( dpy, p, gc, 0, 0, width, height ); XSetForeground( dpy, gc, 1 ); XDrawLine( dpy, p, gc, diam>>1, diam>>1, x2, y2 ); XShapeCombineMask( dpy, XtWindow(w), ShapeBounding, -(w->core.border_width), -(w->core.border_width), p, ShapeSet ); XSetForeground( dpy, gc, 0 ); XFillRectangle( dpy, p, gc, 0, 0, width, height ); if (w->core.width < w->core.height) { diam = w->core.width; x2 = diam>>1; y2 = w->core.height - x2 - 1; } else { diam = w->core.height; y2 = diam>>1; x2 = w->core.width - y2 - 1; } values.line_width = diam; values.foreground = 1; XChangeGC (dpy, gc, GCLineWidth|GCForeground, &values); XDrawLine( dpy, p, gc, diam>>1, diam>>1, x2, y2 ); XShapeCombineMask( dpy, XtWindow(w), ShapeClip, 0, 0, p, ShapeSet ); XFreePixmap( dpy, p ); XFreeGC (dpy, gc ); } static ShapeEllipseOrRoundedRectangle(w, ellipse, ew, eh) Widget w; Boolean ellipse; int ew, eh; { Display *dpy = XtDisplay(w); unsigned width = w->core.width + (w->core.border_width<<1); unsigned height = w->core.height + (w->coreG XTERM021.BCKsr "[MAHAN.XTERM.LIB.XMU]SHAPEWIDG.C;2M a .border_width<<1); Pixmap p = XCreatePixmap( dpy, XtWindow(w), width, height, 1 ); XGCValues values; GC gc; values.foreground = 0; gc = XCreateGC (dpy, p, GCForeground, &values ); XFillRectangle( dpy, p, gc, 0, 0, width, height ); XSetForeground (dpy, gc, 1); if (!ellipse) XmuFillRoundedRectangle( dpy, p, gc, 0, 0, width, height, ew, eh ); else XFillArc( dpy, p, gc, 0, 0, width, height, 0, 360*64 ); XShapeCombineMask( dpy, XtWindow(w), ShapeBounding, -(w->core.border_width), -(w->core.border_width), p, ShapeSet ); XSetForeground (dpy, gc, 0); XFillRectangle( dpy, p, gc, 0, 0, width, height ); XSetForeground (dpy, gc, 1); if (!ellipse) XmuFillRoundedRectangle( dpy, p, gc, 0, 0, w->core.width, w->core.height, ew, eh ); else XFillArc( dpy, p, gc, 0, 0, w->core.width, w->core.height, 0, 360*64 ); XShapeCombineMask( dpy, XtWindow(w), ShapeClip, 0, 0, p, ShapeSet ); XFreePixmap( dpy, p ); XFreeGC (dpy, gc); } "*[MAHAN.XTERM.LIB.XMU]SHAREDLIB.C;1+,s ./@ 4PF-r 0123KPWO56PF7p$F8p\9G@HJ  XTERM021.BCKs r "[MAHAN.XTERM.LIB.XMU]SHAREDLIB.C;18/* * $XConsortium: sharedlib.c,v 1.3 89/10/09 14:28:56 jim Exp $ * * Copyright 1989 Massachusetts Institute of Technology * * This file is used to force shared libraries to get the right routines. */ #if defined(SUNSHLIB) && !defined(SHAREDCODE) #include /* * The following hack is used by XmuConvertStandardSelection to get the * following class records. Without these, a runtime undefined symbol error * occurs. */ extern WidgetClass applicationShellWidgetClass,wmShellWidgetClass; WidgetClass get_applicationShellWidgetClass() { return applicationShellWidgetClass; } WidgetClass get_wmShellWidgetClass() { return wmShellWidgetClass; } #else static int dummy; /* avoid warning from ranlib */ #endif /* SHAREDCODE && SUNSHLIB */  *[MAHAN.XTERM.LIB.XMU]STDCMAP.C;2+,s./@ 4OF-r 0123KPWO56F7QF8r?9G@HJʿI XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]STDCMAP.C;222O,/* $XConsortium: StdCmap.c,v 1.11 89/10/08 15:04:52 rws Exp $ * * Copyright 1989 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. * * 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: Donna Converse, MIT X Consortium */ #include #ifdef vax11c #include #include #include #include "STDCMAP.H" #else #include #include #include #include #endif /* vaBm XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]STDCMAP.C;22;2Ox11c */ static Status valid_args(); /* argument restrictions */ /* * To create any one standard colormap, use XmuStandardColormap(). * * Create a standard colormap for the given screen, visualid, and visual * depth, with the given red, green, and blue maximum values, with the * given standard property name. Return a pointer to an XStandardColormap * structure which describes the newly created colormap, upon success. * Upon failure, return NULL. * * XmuStandardColormap() calls XmuCreateColormap() to create the map. * * Resources created by this function are not made permanent; that is the * caller's responsibility. */ XStandardColormap *XmuStandardColormap(dpy, screen, visualid, depth, property, cmap, red_max, green_max, blue_max) Display *dpy; /* specifies X server connection */ int screen; /* specifies display screen */ VisualID visualid; /* identifies the visual type */ unsigned int depth; /* identifies the visual type */ Atom property; /* a standard colormap property */ Colormap cmap; /* specifies colormap ID or None */ unsigned long red_max, green_max, blue_max; /* allocations */ { XStandardColormap *stdcmap; Status status; XVisualInfo vinfo_template, *vinfo; long vinfo_mask; int n; /* Match the required visual information to an actual visual */ vinfo_template.visualid = visualid; vinfo_template.screen = screen; vinfo_template.depth = depth; vinfo_mask = VisualIDMask | VisualScreenMask | VisualI XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]STDCMAP.C;22;2OJDepthMask; if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL) return 0; /* Check the validity of the combination of visual characteristics, * allocation, and colormap property. Create an XStandardColormap * structure. */ if (! valid_args(vinfo, red_max, green_max, blue_max, property) || ((stdcmap = XAllocStandardColormap()) == NULL)) { XFree((char *) vinfo); return 0; } /* Fill in the XStandardColormap structure */ if (cmap == DefaultColormap(dpy, screen)) { /* Allocating out of the default map, cannot use XFreeColormap() */ Window win = XCreateWindow(dpy, RootWindow(dpy, screen), 1, 1, 1, 1, 0, 0, InputOnly, vinfo->visual, (unsigned long) 0, (XSetWindowAttributes *)NULL); stdcmap->killid = (XID) XCreatePixmap(dpy, win, 1, 1, depth); XDestroyWindow(dpy, win); stdcmap->colormap = cmap; } else { stdcmap->killid = ReleaseByFreeingColormap; stdcmap->colormap = XCreateColormap(dpy, RootWindow(dpy, screen), vinfo->visual, AllocNone); } stdcmap->red_max = red_max; stdcmap->green_max = green_max; stdcmap->blue_max = blue_max; if (property == XA_RGB_GRAY_MAP) stdcmap->red_mult = stdcmap->green_mult = stdcmap->blue_mult = 1; else { stdcmap->red_mult = (red_max > 0) ? (green_max + 1) * (blue_max + 1) : 0; stdcmap->green_mult = (green_max > 0) ? blue_max + 1 : 0; stdcmap->blue_mult = (blue_max > 0) ? 1 : 0; } stdcmap->base_pixel = 0; /* base pixel may change */ s-z XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]STDCMAP.C;2H;2Ofk tdcmap->visualid = vinfo->visualid; /* Make the colormap */ status = XmuCreateColormap(dpy, stdcmap); /* Clean up */ XFree((char *) vinfo); if (!status) { /* Free the colormap or the pixmap, if we created one */ if (stdcmap->killid == ReleaseByFreeingColormap) XFreeColormap(dpy, stdcmap->colormap); else if (stdcmap->killid != None) XFreePixmap(dpy, stdcmap->killid); XFree((char *) stdcmap); return (XStandardColormap *) NULL; } return stdcmap; } /****************************************************************************/ static Status valid_args(vinfo, red_max, green_max, blue_max, property) XVisualInfo *vinfo; /* specifies visual */ unsigned long red_max, green_max, blue_max; /* specifies alloc */ Atom property; /* specifies property name */ { unsigned long ncolors; /* number of colors requested */ /* Determine that the number of colors requested is <= map size */ if ((vinfo->class == DirectColor) || (vinfo->class == TrueColor)) { unsigned long mask; mask = vinfo->red_mask; while (!(mask & 1)) mask >>= 1; if (red_max > mask) return 0; mask = vinfo->green_mask; while (!(mask & 1)) mask >>= 1; if (green_max > mask) return 0; mask = vinfo->blue_mask; while (!(mask & 1)) mask >>= 1; if (blue_max > mask) return 0; } else if (property == XA_RGB_GRAY_MAP) { ncolors = red_max + green_max + blue_max + 1; if (ncolors > vinfo->colormap_size) return 0; } else { ncolors = (red_max + 1) *5  XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]STDCMAP.C;2C;3O$ (green_max + 1) * (blue_max + 1); if (ncolors > vinfo->colormap_size) return 0; } /* Determine that the allocation and visual make sense for the property */ switch (property) { case XA_RGB_DEFAULT_MAP: if ((red_max == 0 || green_max == 0 || blue_max == 0) || (vinfo->class != PseudoColor && vinfo->class != DirectColor && vinfo->class != GrayScale)) return 0; break; case XA_RGB_RED_MAP: if ((vinfo->class != PseudoColor && vinfo->class != DirectColor) || (red_max == 0)) return 0; break; case XA_RGB_GREEN_MAP: if ((vinfo->class != PseudoColor && vinfo->class != DirectColor) || (green_max == 0)) return 0; break; case XA_RGB_BLUE_MAP: if ((vinfo->class != PseudoColor && vinfo->class != DirectColor) || blue_max == 0) return 0; break; case XA_RGB_BEST_MAP: if (vinfo->class == GrayScale || vinfo->class == StaticGray || red_max == 0 || green_max == 0 || blue_max == 0) return 0; break; case XA_RGB_GRAY_MAP: if (vinfo->class == StaticColor || vinfo->class == TrueColor || red_max == 0 || blue_max == 0 || green_max == 0) return 0; break; default: return 0; } return 1; } l XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]STDCMAP.H;1C;34 *[MAHAN.XTERM.LIB.XMU]STDCMAP.H;1+,s./@ 4`] F-r 0123KPWO56`] F7GF8Ss9G@HJ/* * $XConsortium: StdCmap.h,v 1.1 89/07/14 17:51:56 jim Exp $ * * Copyright 1988 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. * * The X Window System is a Trademark of MIT. * * The interfaces described by this header file are for miscellaneous utilities * and are not part of the Xlib standard. */ #ifndef _XMU_STDCMAP_H_ #define _XMU_STDCMAP_H_ Status XmuAllStandardColormaps(MJ XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]STDCMAP.H;1C;3 /* Display* */ ); Status XmuCreateColormap( /* Display*, XStandardColormap* */ ); void XmuDeleteStandardColormap( /* Display*, int, Atom */ ); Status XmuGetColormapAllocation( /* XVisualInfo*, Atom, unsigned long, ... */); Status XmuLookupColormap( /* Display*, int, VisualID, ... */ ); XStandardColormap *XmuStandardColormap( /* Display*, int, VisualID, ... */ ); Status XmuVisualStandardColormaps( /* Display*, int, VisualID, ... */ ); #endif /* _XMU_STDCMAP_H_ */ *[MAHAN.XTERM.LIB.XMU]STDSEL.H;1+, s ./@ 4M4αF-r 0123KPWO564αF7YF8`9G@HJ/* * $XConsortium: StdSel.h,v 1.1 89/07/14 17:51:56 jim Exp $ * * Copyright 1988 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 publiƳgqO Gt*~B|p9use> d@_\A>EP.a5g`z-^vwB$=Wpq?Yb^Q)/`'_7vAlSjt'\,Y,F`??{R/w6"_*t8(ugF;]u$va]A(/8:}U=aZmH:ycUd+KJ<, #1cy:alqo1bl+5dG|*~wl ""w(!@vJ2sLD'9I3+x1Df, u @_"u %;I{FlNB{`k:,!Y}BW}E:]a{vc2=G6]p\ kS}Kg8[|D%$R3*b=BTK]"3? %UAH\S !]:8Qu5EZ&^O]\oF i;50_xnx+o15LV,P[NrG&y%"\$aN (,`*sL+G!;l#BQ%hF),lKaMGguf^\$wi Nfod%$r&)p!hdT}4IV= A%;ea_}r u^f6ui@z~la9I 9otyys:Ho?E Eubm@>'Tj1Q$ '+%QEI  =Epoc@>f>(3kJ%18B+"!s#ut c+[rd-X"wG tA41VFV<Q5Bxh^s}#T %0}G YUu+q2p:W}L %TZQI0tTg.C iz 37X>>A$PKuQ6B0m: #)[{;y 56_LiHCX>/X|m7 D/Kb=Vq7_HEC7%}JsD" x)QR$|0!gfR>.F MoS5XC:]c2&Sz"zB.gxxyVY ^Tu-tDLC5|;j<!8Ks<8@F!=aSL Jso2@9j= Oqn'y89v{= 8 7QNu@)u.#{1CY AZ4AsO2DSO2%(N g0yA4=JCs0< ;Qe+f[PYY  m_1{Sfnz;EY8XG1<I#17BHZe@~Mf'P}x]BaQ/Weg.zB%QzRs- . I/?lrLTiiU 78wx<\a t f0gqFq:3_f<?iBKr43%HGSCfR<;HDv5>5w-3>^#`b'}4@"CbH*L3 IW{(/,;nmD]sDlpl3{9+kg 5u.(" MmhCeZwN -= r cK3Tp 9 nq >eI2:*rt!(E2g(Teg`~0 (84;Uhzx+3e1B XTERM021.BCK s r [MAHAN.XTERM.LIB.XMU]STDSEL.H;1.C;3*city 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. * * The X Window System is a Trademark of MIT. * * The interfaces described by this header file are for miscellaneous utilities * and are not part of the Xlib standard. */ #ifndef _XMU_SELECTION_H_ #define _XMU_SELECTION_H_ Boolean XmuConvertStandardSelection( /* Widget, Time, Atom*, ... */ ); #endif /* _XMU_SELECTION_H_ */ "*[MAHAN.XTERM.LIB.XMU]STRTOBMAP.C;2+, s . /@ 4T EF-r 0123KPWO56EF7VqF8Jޅ9G@HJ$'k XTERM021.BCK s r "[MAHAN.XTERM.LIB.XMU]STRTOBMAP.C;23T #ifndef lint static char rcsid[] = "$XConsortium: StrToBmap.c,v 1.9 89/10/09 16:25:32 jim 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. ******************************************************************/ #ifdef vax11c #include #include #include "CONVERTERS.H" #include "DRAWING.H" #else #include #include #include #include #endif /* vax11c */ /* * XmuConvertStringToBitmap: * * creates a depth-1 Pixmap suitable for window manager icons. * "string" represents a bitmap(1) filename which may be absolute, * or relative to the global resource bitmapFilePath, class * BitmapFilePath. If the resource is not defined, the default * value is the build symbol BITMAPDIR. * * shares lots of code with XmuConvertStringToCursor. * * To use, include the following in your ClassInitialize procedure: static XtConvertArgRec screenConvertArg[] = { {XtBaseOffset, (caddr_t) XtOffset(Widget, core.screen), sizeof(Screen *)} }; XtAddConverter("String", "Bitmap", XmuCvtStringToBitmap, screenConvertArg, XtNumber(screenConvertArg)); * */ #define done(address, type) \ { (*toVal).size = sizeof(type); (*toVal).addr = (caddr_t) address; } /*ARGSUSED*/ void XmuCvtStringToBitmap(args, num_args, fromVal, toVal) XrmValuePtr args; Cardinal *num_args; XrmValuePtr fromVal; XrmValuePtr toVal; { static Pixmap pixmap; /* static for cvt magic */ char *name = (char *)fromVal->addr; if (*num_args != 1) XtErrorMsg("wrongParameters","cvtStringToBitmap","XtToolkitError", "String to pixmap conversion needs screen argument", (String *)NULL, (Cardinal *)NULL); if (strcmp(name, "None") == 0) { pixmap = None; done(&pixmap, Pixmap); return; } if (strcmp(name, "ParentRelative") == 0) { pixmap = ParentRela0 XTERM021.BCK s r "[MAHAN.XTERM.LIB.XMU]STRTOBMAP.C;23T tive; done(&pixmap, Pixmap); return; } pixmap = XmuLocateBitmapFile (*((Screen **) args[0].addr), name, NULL, 0, NULL, NULL, NULL, NULL); if (pixmap != None) { done (&pixmap, Pixmap); } else { XtStringConversionWarning (name, "Pixmap"); return; } }  *[MAHAN.XTERM.LIB.XMU]STRTOBS.C;2+, s . /@ 4P pF-r 0123KPWO56pF7P$F8S9G@HJstatic char rcsid[] = "$XConsortium: StrToBS.c,v 1.0 88/09/05 19:00:53 rws Exp $"; /* * Copyright 1988 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 2 XTERM021.BCK s r  [MAHAN.XTERM.LIB.XMU]STRTOBS.C;2C;3P 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. * */ #ifdef vax11c #include #include "XMU.H" #else #include #include "Xmu.h" #endif /* vax11c */ #define done(address, type) \ { (*toVal).size = sizeof(type); (*toVal).addr = (caddr_t) address; } /* ARGSUSED */ void XmuCvtStringToBackingStore (args, num_args, fromVal, toVal) XrmValue *args; /* unused */ Cardinal *num_args; /* unused */ XrmValuePtr fromVal; XrmValuePtr toVal; { char lowerString[1024]; XrmQuark q; static int backingStoreType; static XrmQuark XtQEnotUseful, XtQEwhenMapped, XtQEalways, XtQEdefault; static int haveQuarks = 0; if (*num_args != 0) XtWarning("String to BackingStore conversion needs no extra arguments"); if (!haveQuarks) { XmuCopyISOLatin1Lowered (lowerString, XtEnotUseful); XtQEnotUseful = XrmStringToQuark(lowerString); XmuCopyISOLatin1Lowered (lowerString, XtEwhenMapped); XtQEwhenMapped = XrmStringToQuark(lowerString); XmuCopyISOLatin1Lowered (lowerString, XtEalways); XtQEalways = XrmStringToQuark(lowerString); XmuCopyISOLatin1Lowered (lowerString, XtEdefault); XtQEdefault = XrmStringToQuark(lowerString); haveQuarks = 1; } XmuCopyISOLatin1Lowered (lowerString, (char *) fromVal->addr); q = Xr{ XTERM021.BCK s r  [MAHAN.XTERM.LIB.XMU]STRTOBS.C;2C;3P 8mStringToQuark (lowerString); if (q == XtQEnotUseful) { backingStoreType = NotUseful; done (&backingStoreType, int); } else if (q == XtQEwhenMapped) { backingStoreType = WhenMapped; done (&backingStoreType, int); } else if (q == XtQEalways) { backingStoreType = Always; done (&backingStoreType, int); } else if (q == XtQEdefault) { backingStoreType = Always + WhenMapped + NotUseful; done (&backingStoreType, int); } else { XtStringConversionWarning((char *) fromVal->addr, "BackingStore"); } } "*[MAHAN.XTERM.LIB.XMU]STRTOCURS.C;2+, s./@ 4T 8pJF-r 0123KPWO56pJF73F8@w^9G@HJ./ XTERM021.BCK sr "[MAHAN.XTERM.LIB.XMU]STRTOCURS.C;23T"#ifndef lint static char rcsid[] = "$XConsortium: StrToCurs.c,v 1.8 89/08/17 15:33:05 jim 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. ******************************************************************/ #ifdef vax11c #include /* 'cause CoreP.h needs it */ #include /* just to do XtConvert() */ #include #define u XTERM021.BCK sr "[MAHAN.XTERM.LIB.XMU]STRTOCURS.C;22TIMAXPATHLEN 256 #include "CONVERTERS.H" #include "DRAWING.H" #else #include /* 'cause CoreP.h needs it */ #include /* just to do XtConvert() */ #include #include /* just to get MAXPATHLEN */ #ifndef MAXPATHLEN #define MAXPATHLEN 256 #endif #include #include #endif /* vax11c */ /* * XmuConvertStringToCursor: * * allows String to specify a standard cursor name (from cursorfont.h), a * font name and glyph index of the form "FONT fontname index [[font] index]", * or a bitmap file name (absolute, or relative to the global resource * bitmapFilePath, class BitmapFilePath). If the resource is not * defined, the default value is the build symbol BITMAPDIR. * * shares lots of code with XmuCvtStringToPixmap, but unfortunately * can't use it as the hotspot info is lost. * * To use, include the following in your ClassInitialize procedure: static XtConvertArgRec screenConvertArg[] = { {XtBaseOffset, (caddr_t) XtOffset(Widget, core.screen), sizeof(Screen *)} }; XtAddConverter("String", "Cursor", XmuCvtStringToCursor, screenConvertArg, XtNumber(screenConvertArg)); * */ #define done(address, type) \ { (*toVal).size = sizeof(type); (*toVal).addr = (caddr_t) address; } #ifndef BITMAPDIR #define BITMAPDIR "/usr/include/X11/bitmaps" #endif #define FONTSPECIFIER "FONT " /*ARGSUSED*/ void XmuCvtStringToCursor(args, num_args, fromVal, toVal) XrmValuePtr args; Cardinal *nu湅~ XTERM021.BCK sr "[MAHAN.XTERM.LIB.XMU]STRTOCURS.C;22Tԑm_args; XrmValuePtr fromVal; XrmValuePtr toVal; { static Cursor cursor; /* static for cvt magic */ char *name = (char *)fromVal->addr; Screen *screen; register int i; char maskname[MAXPATHLEN]; Pixmap source, mask; static XColor bgColor = {0, ~0, ~0, ~0}; /* XXX - make a resource */ static XColor fgColor = {0, 0, 0, 0}; /* XXX - ditto */ int xhot, yhot; int len; if (*num_args != 1) XtErrorMsg("wrongParameters","cvtStringToCursor","XtToolkitError", "String to cursor conversion needs screen argument", (String *)NULL, (Cardinal *)NULL); screen = *((Screen **) args[0].addr); if (0 == strncmp(FONTSPECIFIER, name, strlen(FONTSPECIFIER))) { char source_name[MAXPATHLEN], mask_name[MAXPATHLEN]; int source_char, mask_char, fields; WidgetRec widgetRec; Font source_font, mask_font; XrmValue fromString, toFont; fields = sscanf(name, "FONT %s %d %s %d", source_name, &source_char, mask_name, &mask_char); if (fields < 2) { XtStringConversionWarning( name, "Cursor" ); return; } /* widgetRec is stupid; we should just use XtDirectConvert, * but the names in Xt/Converters aren't public. */ widgetRec.core.screen = screen; fromString.addr = source_name; fromString.size = strlen(source_name); XtConvert(&widgetRec, XtRString, &fromString, XtRFont, &toFont); if (toFont.addr == NULL) { XtStringConversionWarning( name, "Cursor" ); return; } source_font = *(Font*)toFont.addr; switch (fields)# XTERM021.BCK sr "[MAHAN.XTERM.LIB.XMU]STRTOCURS.C;22T { case 2: /* defaulted mask font & char */ mask_font = source_font; mask_char = source_char; break; case 3: /* defaulted mask font */ mask_font = source_font; mask_char = atoi(mask_name); break; case 4: /* specified mask font & char */ fromString.addr = mask_name; fromString.size = strlen(mask_name); XtConvert(&widgetRec, XtRString, &fromString, XtRFont, &toFont); if (toFont.addr == NULL) { XtStringConversionWarning( name, "Cursor" ); return; } mask_font = *(Font*)toFont.addr; } cursor = XCreateGlyphCursor( DisplayOfScreen(screen), source_font, mask_font, source_char, mask_char, &fgColor, &bgColor ); done(&cursor, Cursor); return; } i = XmuCursorNameToIndex (name); if (i != -1) { cursor = XCreateFontCursor (DisplayOfScreen(screen), i); done(&cursor, Cursor); return; } if ((source = XmuLocateBitmapFile (screen, name, maskname, (sizeof maskname) - 4, NULL, NULL, &xhot, &yhot)) == None) { XtStringConversionWarning (name, "Cursor"); } len = strlen (maskname); for (i = 0; i < 2; i++) { strcpy (maskname + len, i == 0 ? "Mask" : "msk"); if ((mask = XmuLocateBitmapFile (screen, maskname, NULL, 0, NULL, NULL, NULL, NULL)) != None) break; } cursor = XCreatePixmapCursor( DisplayOfScreen(screen), source, mask, &fgColor, &bgColor, xhot, yhot ); XFreePixmap( DisplayOfScreen(screen), source ); if (mask != None) XFreePixmap( Display~ = c kmx Teh|[ DxhWKi/\R lwM4[#)2;pWa&W^hL"P 49Jp.Iitf-{(H"Zuk&RX[`YY%]nUd>|DKp/#*MW._!$ +bX. Xm>C515t2n+qy~n:*@EMw!b"Gvdb)&CF@ s @KfKj+|/x5V,CbLMfOSjn@}P Uqv`hf0! {:4 8o< =mgG`WLWcs*g9yUaK>"b+%%+!Bz0T ^${{ YTa<5apfcz: ];EJ56lLi"kQopY*H9B5pNGLK}ku;s k{"1BF7J(.eLO9f3d#53N5( z:)>ZVl etE&|gE OCuutGa|y5%)~n 3l+6v+b5kkf]Rq&W*B=/N`/#gk\Flg_jy"7k%I@ywZr"q,Vf F50?%SG>N:2< *qG@h/k1#hkHxh fNfXRJ|c ZBAun0~Be%zmAQBA(0Lr@ fA152gnJaQy Z]rMVILC -tq>?6E/`O:_QVS2B!sT""aYdK i{ GP"gr)T UM5-Eflp8 r34&[sHy.A&%Gn) 'xJ Pgy !xH,U\EVU FgXTPDDHHs6h1lT)7712jqiCQ2B>ho:u6/2:tpA_OxN1QjmGI% m5Fz7(uc'Q}cvj;- mJh%]T"&eIgt%(iE@bn  Z^c f=mAOU"nu~Y/d'j"<,:>6"~\huPbRUZRT2W${Kk$plM&g%l I5p |N{/-"b[b")TUd 'AdqaQ3j]MHp:F XTERM021.BCK sr "[MAHAN.XTERM.LIB.XMU]STRTOCURS.C;2T% OfScreen(screen), mask ); done(&cursor, Cursor); } "*[MAHAN.XTERM.LIB.XMU]STRTOJUST.C;2+, s ./@ 4M -F-r 0123KPWO56 -F7`F8 ߓ9G@HJstatic char rcsid[] = "$XConsortium: StrToJust.c,v 1.2 89/12/10 10:36:16 rws Exp $"; /* * Copyright 1988 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 iD: XTERM021.BCK s r "[MAHAN.XTERM.LIB.XMU]STRTOJUST.C;2M$n 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. * */ #ifdef vax11c #include #include "XMU.H" #else #include #include "Xmu.h" #endif /* vax11c */ /* ARGSUSED */ void XmuCvtStringToJustify(args, num_args, fromVal, toVal) XrmValuePtr *args; /* unused */ Cardinal *num_args; /* unused */ XrmValuePtr fromVal; XrmValuePtr toVal; { static XtJustify e; static XrmQuark XrmQEleft; static XrmQuark XrmQEcenter; static XrmQuark XrmQEright; static int haveQuarks; XrmQuark q; char *s = (char *) fromVal->addr; char lowerName[1000]; if (s == NULL) return; if (!haveQuarks) { XrmQEleft = XrmStringToQuark(XtEleft); XrmQEcenter = XrmStringToQuark(XtEcenter); XrmQEright = XrmStringToQuark(XtEright); haveQuarks = 1; } XmuCopyISOLatin1Lowered(lowerName, s); q = XrmStringToQuark(lowerName); toVal->size = sizeof(XtJustify); toVal->addr = (caddr_t) &e; if (q == XrmQEleft) { e = XtJustifyLeft; return; } if (q == XrmQEcenter) { e = XtJustifyCenter; return; } if (q == XrmQEright) { e = XtJustifyRight; return; } toVal->size = 0; toVal->addr = NULL; } /P7y XTERM021.BCKsr "[MAHAN.XTERM.LIB.XMU]STRTOLONG.C;2O{"*[MAHAN.XTERM.LIB.XMU]STRTOLONG.C;2+,s./@ 4OjF-r 0123KPWO56jF7 HF89Ɔ9G@HJ/* * $XConsortium: StrToLong.c,v 1.2 89/07/14 18:05:40 jim 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. * * 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 FROMsMҧ XTERM021.BCKsr "[MAHAN.XTERM.LIB.XMU]STRTOLONG.C;2Oz 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. */ #ifdef vax11c #include #include "CONVERTERS.H" #else #include #include "Converters.h" #endif /* vax11c */ #define done(address, type) \ { (*toVal).size = sizeof(type); (*toVal).addr = (caddr_t) address; } void XmuCvtStringToLong (args, num_args, fromVal, toVal) XrmValuePtr args; Cardinal *num_args; XrmValuePtr fromVal; XrmValuePtr toVal; { static long l; if (*num_args != 0) XtWarningMsg("wrongParameters","cvtStringToLong","XtToolkitError", "String to Long conversion needs no extra arguments", (String *) NULL, (Cardinal *)NULL); if (sscanf((char *)fromVal->addr, "%ld", &l) == 1) { done(&l, long); } else { XtStringConversionWarning((char *) fromVal->addr, XtRLong); } } "*[MAHAN.XTERM.LIB.XMU]STRTOORNT.C;2+,s./@ 4M`F-r 0123KPWO56`F7F89G@HJ{ XTERM021.BCKsr "[MAHAN.XTERM.LIB.XMU]STRTOORNT.C;2MWstatic char rcsid[] = "$XConsortium: StrToOrnt.c,v 1.2 89/12/07 10:53:36 rws Exp $"; /* * Copyright 1988 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. * */ #ifdef vax11c #include #include #include "XMU.H" #else #include #include #include #endif /* vax11c */ #define done(address, type) \ { (*toVal).size = sizeof(type); (*toVal).addr = (caddr_t) address; } /* ARGSUSED */ void XmuCvtStringToOrientation(args, num_args, fromVal, toVal) XrmValuePtr *args; /* unused */ Cardinal *num_args; /* unused */ XrmValuePtr fromVal; XrmValuePtr toVal; { static XtOrientation orient; static XrmQuark XtQEhorizontal; static XrmQuark XtQEvertical; static int haveQuarks = 0; XrmQuark q; char lowerName[1000]; if (!haveQuarks) { XtQEhorizontal = Xrmx  XTERM021.BCKsr "[MAHAN.XTERM.LIB.XMU]STRTOORNT.C;2MRStringToQuark(XtEhorizontal); XtQEvertical = XrmStringToQuark(XtEvertical); haveQuarks = 1; } XmuCopyISOLatin1Lowered(lowerName, (char *) fromVal->addr); q = XrmStringToQuark(lowerName); if (q == XtQEhorizontal) { orient = XtorientHorizontal; done(&orient, XtOrientation); return; } if (q == XtQEvertical) { orient = XtorientVertical; done(&orient, XtOrientation); return; } } "*[MAHAN.XTERM.LIB.XMU]STRTOSHAP.C;2+,s. /@ 4N n)zF-r 0123KPWO56)zF7@BF8u,9G@HJstatic char rcsid[] = "$XConsortium: StrToShap.c,v 1.1 89/10/03 11:37:03 swick Exp $"; /* * Copyright 1988 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 usedMl XTERM021.BCKsr "[MAHAN.XTERM.LIB.XMU]STRTOSHAP.C;2N E# 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. * */ #ifdef vax11c #include #include "XMU.H" #else #include #include "Xmu.h" #endif /* vax11c */ /* ARGSUSED */ #define done(type, value) \ { \ if (toVal->addr != NULL) { \ if (toVal->size < sizeof(type)) { \ toVal->size = sizeof(type); \ return False; \ } \ *(type*)(toVal->addr) = (value); \ } \ else { \ static type static_val; \ static_val = (value); \ toVal->size = sizeof(type); \ toVal->addr = (XtPointer)&static_val; \ } \ return True; \ } Boolean XmuCvtStringToShapeStyle(dpy, args, num_args, from, toVal, data) Display *dpy; XrmValue *args; /* unused */ Cardinal *num_args; /* unused */ XrmValue *from; XrmValue *toVal; XtPointer *data; /* unused */ { if ( XmuCompareISOLatin1((char*)from->addr, XtERectangle) == 0 || XmuCompareISOLatin1((char*)from->addr, "ShapeRectangle") == 0) done( int, XmuShapeRectangle ); if ( XmuCompareISOLatin1((char*)from->addr, XtEOval) == 0 || XmuCompareISOLatin1((char*)from->addr, "ShapeOval") == 0) done( int, XmuShapeOval ); if ( XmuCompareISOLatin1((char*)from->addr, XtEEllipse) == 0 || XmuCompareISOLatin1G XTERM021.BCKsr "[MAHAN.XTERM.LIB.XMU]STRTOSHAP.C;22N !t((char*)from->addr, "ShapeEllipse") == 0) done( int, XmuShapeEllipse ); if ( XmuCompareISOLatin1((char*)from->addr, XtERoundedRectangle) == 0 || XmuCompareISOLatin1((char*)from->addr, "ShapeRoundedRectangle") == 0) done( int, XmuShapeRoundedRectangle ); { int style = 0; char ch, *p = (char*)from->addr; while (ch = *p++) { if (ch >= '0' && ch <= '9') { style *= 10; style += ch - '0'; } else break; } if (ch == '\0' && style <= XmuShapeRoundedRectangle) done( int, style ); } XtDisplayStringConversionWarning( dpy, (char*)from->addr, XtRShapeStyle ); return False; } "*[MAHAN.XTERM.LIB.XMU]STRTOWIDG.C;1+,s . /@ 4W 9F-r 0123KPWO569F7`CF8l9G@HJR XTERM021.BCKs r "[MAHAN.XTERM.LIB.XMU]STRTOWIDG.C;12W ;#ifndef lint static char Xrcsid[] = "$XConsortium: StrToWidg.c,v 1.3 89/09/22 12:11:59 keith Exp $"; #endif /* lint */ /* Copyright 1988 Massachusetts Institute of Technology, Cambridge, Massachusetts. * * XmuCvtStringToWidget * * static XtConvertArgRec parentCvtArgs[] = { * {XtBaseOffset, (caddr_t)XtOffset(Widget, core.parent), sizeof(Widget)}, * }; * * matches the string against the name of the immediate children (normal * or popup) of the parent. If none match, compares string to classname * & returns first match. Case is significant. */ #ifndef vax11c #include #endif /* !vax11c */ #ifdef vax11c #include #include #include #else #include #include #include #endif /* vax11c */ #define done(address, type) \ { toVal->size = sizeof(type); \ toVal->addr = (caddr_t) address; \ return; \ } /* ARGSUSED */ void XmuCvtStringToWidget(args, num_args, fromVal, toVal) XrmValuePtr args; /* parent */ Cardinal *num_args; /* 1 */ XrmValuePtr fromVal; XrmValuePtr toVal; { static Widget widget, *widgetP, parent; XrmName name = XrmStringToName(fromVal->addr); int i; if (*num_args != 1) XtErrorMsg("wrongParameters", "cvtStringToWidget", "xtToolkitError", "StringToWidget conversion needs parent arg", NULL, 0); parent = *(Widget*)args[0].addr; /* try to match names of normal children */ if (XtIsComposiEl XTERM021.BCKs r "[MAHAN.XTERM.LIB.XMU]STRTOWIDG.C;12W te(parent)) { i = ((CompositeWidget)parent)->composite.num_children; for (widgetP = ((CompositeWidget)parent)->composite.children; i; i--, widgetP++) { if ((*widgetP)->core.xrm_name == name) { widget = *widgetP; done(&widget, Widget); } } } /* try to match names of popup children */ i = parent->core.num_popups; for (widgetP = parent->core.popup_list; i; i--, widgetP++) { if ((*widgetP)->core.xrm_name == name) { widget = *widgetP; done(&widget, Widget); } } /* try to match classes of normal children */ if (XtIsComposite(parent)) { i = ((CompositeWidget)parent)->composite.num_children; for (widgetP = ((CompositeWidget)parent)->composite.children; i; i--, widgetP++) { if ((*widgetP)->core.widget_class->core_class.xrm_class == name) { widget = *widgetP; done(&widget, Widget); } } } /* try to match classes of popup children */ i = parent->core.num_popups; for (widgetP = parent->core.popup_list; i; i--, widgetP++) { if ((*widgetP)->core.widget_class->core_class.xrm_class == name) { widget = *widgetP; done(&widget, Widget); } } XtStringConversionWarning(fromVal->addr, "Widget"); toVal->addr = NULL; toVal->size = 0; } [U 2  F%(OJ,u|;|lWWTLB}u xR5(-U+IPCcZ{h# @kqFu  9#<#qXijtS}1}lxgPh ?aBD}Y2R~-u<(9,՝*R#|2eA_rY|$;az<`.p?Ib /\:*)`co333O=}g7b0l@e_u=W>cEBb8tl$:[97>;S}ުE}OzC(u %:J'e&}-gC'Wu"k{]h8W4COt=- 3(~%WMuWP*I}$oK9z@fQ>sCbexrW=sdEJ1#D)b'k6:sKo nn4W'aW wcXa"duQ5Dd\5-o) $TOH 7 `rSE(1(iybB }9/OG% /EP2."k%R%Y"X1EcRC~"dV-\I ]mX8GUw z>r\k IUw+V74[1~ hcBUus_aVX*Heh`907uBa_Jr[>X|e~2X.lOaTgg3!Eyex|g*~xr^tfK^y[ e';eIw D 7{ifnLO.58ay -x6D2Jl99by@M\#3pF:_\#&14gS -eTI1KCUa;(-joAs' d&31,Qpf6szP5f-g;{lcrAFna{ig7 % 7 bvs=vo a4kg\-<},a&Dq0lz1 Ia>M$*&-Tjxu033r8Nlp^xJ3j9fn[7t*{#2 3uzr@=2Kt]?szXY3D97{v>6,i!]"_VfP\;kff(R;=5!ty.YXKLS)P|'9/5>|^/pq)C0gr%z 80vTN4bt#l8:Z8]B*>66jX%dh%p{}>wg+CXCJ{w4%O4z6 >t_DIj:j$iflw8Bz$N}!Qz;R9R.Tp~[B|p%jX Bv{\=}-< 3WK]m+4B*u??#@lf /Qx-5B[v adX"F@zF .p1?=;O:=Y]qLd"$a/" ?@oF88,G'=soF]pU^Y*KX^}!iNRV_?4O,p-N%<wg*>&*~mZD (} 16|<,R*n`Wa+K>1z.fQr\\opWj'Gw<\`DL I:w_pUOIK ;Lo^ 1{[m+S0|(&I{zUU|{)nBwss4&8LCd.#tZ{,J\;2*67Ry  &O(~+?htpo66<5Pk !!,oW2 ?iij6W4(#2!|DR\Zr  iy93EtA`1$^o5Vw XTERM021.BCKs r  [MAHAN.XTERM.LIB.XMU]SYSUTIL.H;12;2H *[MAHAN.XTERM.LIB.XMU]SYSUTIL.H;1+,s ./@ 4 =F-r 0123KPWO56=F7fF8@ٛ9G@HJ/* * $XConsortium: SysUtil.h,v 1.1 89/09/22 12:07:37 jim Exp $ * * 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 FROMf2{ XTERM021.BCKs r  [MAHAN.XTERM.LIB.XMU]SYSUTIL.H;12;2 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 _SYSUTIL_H_ #define _SYSUTIL_H_ extern int XmuGetHostname(); #endif /* _SYSUTIL_H_ */ #*[MAHAN.XTERM.LIB.XMU]UPDMAPHINT.C;1+,s./@ 4O}@ЩF-r 0123KPWO56@ЩF7@F8@؇9G@HJ/* * $XConsortium: UpdMapHint.c,v 1.1 89/09/22 12:07:37 jim Exp $ * * 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| XTERM021.BCKsr #[MAHAN.XTERM.LIB.XMU]UPDMAPHINT.C;1O" 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: Jim Fulton, MIT X Consortium */ #include #ifdef vax11c #include #include #else #include #include #endif /* vax11c */ Bool XmuUpdateMapHints (dpy, w, hints) Display *dpy; Window w; XSizeHints *hints; { static XSizeHints *shp = NULL; if (!hints) { /* get them first */ long supp; if (!shp) { shp = XAllocSizeHints(); if (!shp) return False; } if (!XGetWMNormalHints (dpy, w, shp, &supp)) return False; hints = shp; } hints->flags &= ~(PPosition|PSize); hints->flags |= (USPosition|USSize); XSetWMNormalHints (dpy, w, hints); return True; } ~V XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]VISCMAP.C;22;2O *[MAHAN.XTERM.LIB.XMU]VISCMAP.C;2+,s./@ 4O Y?F-r 0123KPWO 56Y?F7`tF8:(9G@HJ/* $XConsortium: VisCmap.c,v 1.10 89/10/08 15:05:47 rws Exp $ * * Copyright 1989 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. * * 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 RESUL XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]VISCMAP.C;22;2O(HTING 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: Donna Converse, MIT X Consortium */ #include #include #ifdef vax11c #include #include #include #include "STDCMAP.H" #else #include #include #include #include #endif /* vax11c */ /* * To create all of the appropriate standard colormaps for a given visual on * a given screen, use XmuVisualStandardColormaps. * * Define all appropriate standard colormap properties for the given visual. * If replace is true, any previous definition will be removed. * If retain is true, new properties will be retained for the duration of * the server session. Return 0 on failure, non-zero on success. * On failure, no new properties will be defined, and, old ones may have * been removed if replace was True. * * Not all standard colormaps are meaningful to all visual classes. This * routine will check and define the following properties for the following * classes, provided that the size of the colormap is not too small. * * DirectColor and PseudoColor * RGB_DEFAULT_MAP * RGB_BEST_MAP * RGB_RED_MAP * RGB_GREEN_MAP * RGB_BLUE_MAP * RGB_GRAY_MAP * * TrueColor and StaticColor * RGB_BEST_MAP * * GrayScale and StaticGray * `  XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]VISCMAP.C;22;2O RGB_GRAY_MAP */ Status XmuVisualStandardColormaps(dpy, screen, visualid, depth, replace, retain) Display *dpy; /* specifies server connection */ int screen; /* specifies screen number */ VisualID visualid; /* specifies the visual */ unsigned int depth; /* specifies the visual */ Bool replace; /* specifies whether to replace */ Bool retain; /* specifies whether to retain */ { Status status; int n; long vinfo_mask; XVisualInfo vinfo_template, *vinfo; vinfo_template.screen = screen; vinfo_template.visualid = visualid; vinfo_template.depth = depth; vinfo_mask = VisualScreenMask | VisualIDMask | VisualDepthMask; if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL) return 0; if (vinfo->colormap_size <= 2) { /* Monochrome visuals have no standard maps; considered successful */ XFree((char *) vinfo); return 1; } switch (vinfo->class) { case PseudoColor: case DirectColor: status = XmuLookupStandardColormap(dpy, screen, visualid, depth, XA_RGB_DEFAULT_MAP, replace,retain); if (!status) break; status = XmuLookupStandardColormap(dpy, screen, visualid, depth, XA_RGB_GRAY_MAP, replace, retain); if (!status) { XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); break; } status = XmuLookupStandardColormap(dpy, screen, visualid, depth, XA_RGB_RED_MAP, replace, retain); if (!status) { XmuDeleteStandardColormap(dpy, screen, &ҋ XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]VISCMAP.C;22;2O; XA_RGB_DEFAULT_MAP); XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP); break; } status = XmuLookupStandardColormap(dpy, screen, visualid, depth, XA_RGB_GREEN_MAP, replace, retain); if (!status) { XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP); XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP); break; } status = XmuLookupStandardColormap(dpy, screen, visualid, depth, XA_RGB_BLUE_MAP, replace, retain); if (!status) { XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP); XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP); XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP); break; } /* fall through */ case StaticColor: case TrueColor: status = XmuLookupStandardColormap(dpy, screen, visualid, depth, XA_RGB_BEST_MAP, replace, retain); if (!status && (vinfo->class == PseudoColor || vinfo->class == DirectColor)) { XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP); XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP); XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP); XmuDeleteStandardColormap(dpy, screen, XA_RGB_BLUE_MAP); } break; /* the end for PseudoColor, DirectColor, StaticColor, and TrueColor */ case GrayScale: status = XmuLookupStandardColormap(B*J XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]VISCMAP.C;22;2O7 dpy, screen, visualid, depth, XA_RGB_DEFAULT_MAP, replace, retain); if (! status) break; /* fall through */ case StaticGray: status = XmuLookupStandardColormap(dpy, screen, visualid, depth, XA_RGB_GRAY_MAP, replace, retain); if (! status && vinfo->class == GrayScale) { XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); break; } } XFree((char *) vinfo); return status; }  *[MAHAN.XTERM.LIB.XMU]WINUTIL.H;1+,s./@ 4nJF-r 0123KPWO56JF7@F8Y9G@HJ/* * $XConsortium: WinUtil.h,v 1.3 89/09/22 12:10:20 jim Exp $ * * Copyright 1988 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 publ1  XTERM021.BCKsr  [MAHAN.XTERM.LIB.XMU]WINUTIL.H;12m_icity 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. * * The X Window System is a Trademark of MIT. * * The interfaces described by this header file are for miscellaneous utilities * and are not part of the Xlib standard. */ #ifndef _XMU_WINDOWUTIL_H_ #define _XMU_WINDOWUTIL_H_ extern Window XmuClientWindow(); extern Bool XmuUpdateMapHints(); extern Screen *XmuScreenOfWindow(); #endif /* _XMU_WINDOWUTIL_H_ */ *[MAHAN.XTERM.LIB.XMU]XCT.C;2+,s .#/@ 4M#!?F-r 0123KPWO"56?F7SF8È9G@HJ XTERM021.BCKs r [MAHAN.XTERM.LIB.XMU]XCT.C;2T.C;2M#}/* * $XConsortium: Xct.c,v 1.11 89/11/30 16:47:28 rws Exp $ * Copyright 1989 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. * */ #include #ifdef vax11c #include "XCT.H" #else #include "Xct.h" #endif /* vax11c */ #define UsedGraphic 0x0001 #define UsedDirection 0x0002 typedef struct _XctPriv { XctString ptr; XctString ptrend; unsigned flags; XctHDirection *dirstack; unsigned dirsize; char **encodings; unsigned enc_count; XctString itembuf; unsigned buf_count; } *XctPriv; #define IsMore(priv) ((priv)->ptr != (priv)->ptrend) #define AmountLeft(priv) ((priv)->ptrend - (priv)->ptr) char *malloc(); char *realloc(); #define HT 0x09 #define NL 0x0a #define ESC 0x1b #define CSI 0x9b #define IsLegalC0(data, c) (((c) == HT) || ((c) == NL) || \ (((data)->version > XctVersion) && \ ((data)->flags & XctAcceptC0Extensions))) 2kt?  ucfkqM,-+Fk{ZOI] %u/ l ^pFRSq$NVv%Q(sfI@g `zJ3j.]/Iov'gr5O WE z: A:\uCio7 5CvX X66WeSA2e$rxO/ fa;ujt5:,;d_U@o 93&<5ERuv@PgQc3B~pEGlp6$6 0e,Z#/J_1s?Is7zY&i%ko4}GSS"JAoir LJ5T|f= WtC-X64dKWJ iI:Mw1=gY}( ek31 2Q 8tE\e1 $ ^6!/#'Z+Xc5P$U5O2$s3\1hY[#z AMwZ?\q"''h)DKni/,+Qk "G;sW>f ^)k x1: s0C5G? zS3~B]? ;'wU7u^7 b|08jPCc"#!Vz{|:=- "st uO$+o/9,39gw'f+-Q;BkP&+?8w:&+,"LW16s(_^cJw36HUF`mFYpUL*+QIL]56Xnya6991VyUdl jS]9\&uy1?g0 sGvXWDdSyb;y;QD*Ybp 3 !U0 Or7XfRT0%"_P+i!F:I8~kn~%qAe&v& 9tъm^,HWs%z4,Gv !FmZf8+NlHb0.9:`?/j"ihHz#wbb(c8dQI)`p@}GIv?SK#GCe7uHmjlrigh}`p%HqJ^V|FuucL%7Int1,8 R@0GT5*rm4 q$?|HGw/V]J32!glh}jps?yvc `w~"7B!5 Y'x~^{FsH|{5Q?. 3o 1-8 \ LBa>M!|aZ+D]I{D q ;0O/,s,*y*);k_VG\b;uE14JO8/sPD*in>MHCo>}UJY8M cgY$#9f+qiyU7SED ~)'vA]g~&No2NCE}0Ed12{V "~M:]cY @M X]0HDe5kQP=R?5"Ȕ,,V,O V7E,Gbc=+ 5)cDFZ-U^W?/? n .:|n_41HfQm.;}-7? _$2P Os2+_ ڴ XTERM021.BCKs r [MAHAN.XTERM.LIB.XMU]XCT.C;2T.C;2M#0 #define IsLegalC1(priv, c) (((data)->version > XctVersion) && \ ((data)->flags & XctAcceptC1Extensions)) #define IsI2(c) (((c) >= 0x20) && ((c) <= 0x2f)) #define IsI3(c) (((c) >= 0x30) && ((c) <= 0x3f)) #define IsESCF(c) (((c) >= 0x30) && ((c) <= 0x7e)) #define IsCSIF(c) (((c) >= 0x40) && ((c) <= 0x7e)) #define IsC0(c) ((c) <= 0x1f) #define IsGL(c) (((c) >= 0x20) && ((c) <= 0x7f)) #define IsC1(c) (((c) >= 0x80) && ((c) <= 0x9f)) #define IsGR(c) ((c) >= 0xa0) #define HasC 1 #define HasGL 2 #define HasGR 4 #define ToGL 8 static void ComputeGLGR(data) register XctData data; { /* XXX this will need more work if more sets are registered */ if ((data->GL_set_size == 94) && (data->GL_char_size == 1) && (data->GL[0] == '\102') && (data->GR_set_size == 96) && (data->GR_char_size == 1)) data->GLGR_encoding = data->GR_encoding; else if ((data->GL_set_size == 94) && (data->GL_char_size == 1) && (data->GL[0] == '\112') && (data->GR_set_size == 94) && (data->GR_char_size == 1)) data->GLGR_encoding = data->GR_encoding; else data->GLGR_encoding = (char *)NULL; } static int HandleGL(data, c) register XctData data; unsigned char c; { switch (c) { case 0x42: data->GL = "\102"; data->GL_encoding = "ISO8859-1"; break; case 0x4a: data->GL = "\112"; data->GL_encoding = "JISX0201.1976-0"; break; default: return 0; } data->GL_set_size = 94; data->GL_char_size = 1; ComputeGLGR(data); return 1; } static i