| 1 |
|
#ifndef lint |
| 2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
| 2 |
> |
static const char RCSid[] = "$Id$"; |
| 3 |
|
#endif |
| 4 |
– |
|
| 5 |
– |
/* Copyright (c) 1989 Regents of the University of California */ |
| 6 |
– |
|
| 4 |
|
/* |
| 5 |
|
* x11twind.c - routines for X11 text windows. |
| 6 |
|
* |
| 11 |
|
* 9/26/88 |
| 12 |
|
*/ |
| 13 |
|
|
| 14 |
+ |
#include "copyright.h" |
| 15 |
+ |
|
| 16 |
|
#include <stdio.h> |
| 17 |
|
|
| 18 |
+ |
#include <stdlib.h> |
| 19 |
+ |
|
| 20 |
|
#include <X11/Xlib.h> |
| 21 |
|
|
| 22 |
|
#include "x11twind.h" |
| 23 |
|
|
| 24 |
|
#ifndef BSD |
| 25 |
|
#define bzero(d,n) (void)memset(d,0,n) |
| 25 |
– |
extern char *memset(); |
| 26 |
|
#endif |
| 27 |
|
|
| 28 |
|
#define checkcurs(t) if ((t)->cursor) togglecurs(t) |
| 34 |
|
#define Height(f) ((f)->ascent + (f)->descent) |
| 35 |
|
#define YStart(f) ((f)->ascent) |
| 36 |
|
|
| 37 |
< |
extern char *calloc(), *malloc(); |
| 37 |
> |
static void togglecurs(); |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
TEXTWIND * |
| 41 |
< |
xt_open(dpy, gc, parent, x, y, width, height, bw, fontname) |
| 42 |
< |
Display *dpy; |
| 43 |
< |
GC gc; |
| 44 |
< |
Window parent; |
| 45 |
< |
int x, y; |
| 46 |
< |
int width, height; |
| 47 |
< |
int bw; |
| 48 |
< |
char *fontname; |
| 41 |
> |
xt_open(dpy, parent, x, y, width, height, bw, fore, back, fontname) |
| 42 |
> |
Display *dpy; |
| 43 |
> |
Window parent; |
| 44 |
> |
int x, y; |
| 45 |
> |
int width, height; |
| 46 |
> |
int bw; |
| 47 |
> |
unsigned long fore, back; |
| 48 |
> |
char *fontname; |
| 49 |
|
{ |
| 50 |
|
register int i; |
| 51 |
|
register TEXTWIND *t; |
| 54 |
|
return(NULL); |
| 55 |
|
|
| 56 |
|
t->dpy = dpy; |
| 57 |
< |
t->w = XCreateSimpleWindow(dpy, parent, x, y, width, height, bw, |
| 58 |
< |
BlackPixel(dpy,DefaultScreen(dpy)), |
| 59 |
< |
WhitePixel(dpy,DefaultScreen(dpy))); |
| 60 |
< |
/* |
| 61 |
< |
t->w = XCreateWindow(dpy, parent, x, y, width, height, bw, 0, |
| 62 |
< |
CopyFromParent, CopyFromParent, 0, 0); |
| 63 |
< |
*/ |
| 64 |
< |
|
| 57 |
> |
t->w = XCreateSimpleWindow(dpy, parent, x, y, width, height, |
| 58 |
> |
bw, fore, back); |
| 59 |
|
if (t->w == 0) |
| 60 |
|
return(NULL); |
| 61 |
|
XMapWindow(dpy, t->w); |
| 65 |
|
|
| 66 |
|
/* if (!t->f.fixedwidth) check for fixedwidth later |
| 67 |
|
return(NULL); */ |
| 74 |
– |
t->gc = XCreateGC(dpy,t->w,0,NULL); |
| 68 |
|
|
| 69 |
< |
XCopyGC(dpy, gc, ~0L, t->gc); |
| 70 |
< |
|
| 69 |
> |
t->gc = XCreateGC(dpy,t->w,0,NULL); |
| 70 |
> |
XSetState(dpy, t->gc, fore, back, GXcopy, AllPlanes); |
| 71 |
|
XSetFont(dpy, t->gc, t->f->fid); |
| 79 |
– |
XSetFunction(dpy, t->gc, GXcopy); |
| 72 |
|
|
| 73 |
|
t->nc = (width - LEFTMAR) / |
| 74 |
|
Width(t->f); /* number of columns */ |
| 88 |
|
} |
| 89 |
|
|
| 90 |
|
|
| 91 |
< |
xt_puts(s, t) /* output a string */ |
| 100 |
< |
register char *s; |
| 101 |
< |
TEXTWIND *t; |
| 102 |
< |
{ |
| 103 |
< |
int oldcurs; |
| 104 |
< |
|
| 105 |
< |
oldcurs = xt_cursor(t, TNOCURS); /* for efficiency */ |
| 106 |
< |
while (*s) |
| 107 |
< |
xt_putc(*s++, t); |
| 108 |
< |
xt_cursor(t, oldcurs); |
| 109 |
< |
} |
| 110 |
< |
|
| 111 |
< |
|
| 91 |
> |
void |
| 92 |
|
xt_putc(c, t) /* output a character */ |
| 93 |
< |
char c; |
| 93 |
> |
int c; |
| 94 |
|
register TEXTWIND *t; |
| 95 |
|
{ |
| 96 |
+ |
char ch[2]; |
| 97 |
+ |
|
| 98 |
|
checkcurs(t); |
| 99 |
|
switch (c) { |
| 100 |
|
case '\n': |
| 115 |
|
default: |
| 116 |
|
if (t->c >= t->nc) |
| 117 |
|
xt_putc('\n', t); |
| 118 |
+ |
ch[0] = c; ch[1] = '\0'; |
| 119 |
|
XDrawImageString(t->dpy, t->w, t->gc, LEFTMAR+t->c*Width(t->f), |
| 120 |
< |
YStart(t->f)+t->r*Height(t->f), &c, 1); |
| 120 |
> |
YStart(t->f)+t->r*Height(t->f), ch, 1); |
| 121 |
|
t->lp[t->r][t->c++] = c; |
| 122 |
|
break; |
| 123 |
|
} |
| 125 |
|
} |
| 126 |
|
|
| 127 |
|
|
| 128 |
+ |
void |
| 129 |
+ |
xt_puts(s, t) /* output a string */ |
| 130 |
+ |
register char *s; |
| 131 |
+ |
TEXTWIND *t; |
| 132 |
+ |
{ |
| 133 |
+ |
int oldcurs; |
| 134 |
+ |
|
| 135 |
+ |
oldcurs = xt_cursor(t, TNOCURS); /* for efficiency */ |
| 136 |
+ |
while (*s) |
| 137 |
+ |
xt_putc(*s++, t); |
| 138 |
+ |
xt_cursor(t, oldcurs); |
| 139 |
+ |
} |
| 140 |
+ |
|
| 141 |
+ |
|
| 142 |
+ |
void |
| 143 |
|
xt_delete(t, r) /* delete a line */ |
| 144 |
|
register TEXTWIND *t; |
| 145 |
|
int r; |
| 167 |
|
} |
| 168 |
|
|
| 169 |
|
|
| 170 |
+ |
void |
| 171 |
|
xt_insert(t, r) /* insert a line */ |
| 172 |
|
register TEXTWIND *t; |
| 173 |
|
int r; |
| 194 |
|
} |
| 195 |
|
|
| 196 |
|
|
| 197 |
+ |
void |
| 198 |
|
xt_redraw(t) /* redraw text window */ |
| 199 |
|
register TEXTWIND *t; |
| 200 |
|
{ |
| 210 |
|
} |
| 211 |
|
|
| 212 |
|
|
| 213 |
+ |
void |
| 214 |
|
xt_clear(t) /* clear text window */ |
| 215 |
|
register TEXTWIND *t; |
| 216 |
|
{ |
| 224 |
|
} |
| 225 |
|
|
| 226 |
|
|
| 227 |
+ |
void |
| 228 |
|
xt_move(t, r, c) /* move to new position */ |
| 229 |
|
register TEXTWIND *t; |
| 230 |
|
int r, c; |
| 255 |
|
} |
| 256 |
|
|
| 257 |
|
|
| 258 |
+ |
void |
| 259 |
|
xt_close(t) /* close text window */ |
| 260 |
|
register TEXTWIND *t; |
| 261 |
|
{ |
| 266 |
|
XDestroyWindow(t->dpy, t->w); |
| 267 |
|
for (i = 0; i < t->nr; i++) |
| 268 |
|
free(t->lp[i]); |
| 269 |
< |
free((char *)t->lp); |
| 270 |
< |
free((char *)t); |
| 269 |
> |
free((void *)t->lp); |
| 270 |
> |
free((void *)t); |
| 271 |
|
} |
| 272 |
|
|
| 273 |
|
|
| 274 |
< |
static |
| 274 |
> |
static void |
| 275 |
|
togglecurs(t) |
| 276 |
|
register TEXTWIND *t; |
| 277 |
|
{ |