*
* Created by: Marc Horowitz <marc@athena.mit.edu>
*
- * $Id: xshow.c,v 1.15 1999/08/13 00:19:52 danw Exp $
+ * $Id$
*
* Copyright (c) 1989 by the Massachusetts Institute of Technology.
* For copying and distribution information, see the file
#include <sysdep.h>
#if (!defined(lint) && !defined(SABER))
-static const char rcsid_xshow_c[] = "$Id: xshow.c,v 1.15 1999/08/13 00:19:52 danw Exp $";
+static const char rcsid_xshow_c[] = "$Id$";
#endif
#include <zephyr/mit-copyright.h>
#include <X11/Xresource.h>
#include "pointer_dictionary.h"
#include "new_memory.h"
+#include "new_string.h"
#include "formatter.h"
#include "variables.h"
#include "zwgc.h"
+#include "X_driver.h"
#include "X_fonts.h"
#include "X_gram.h"
#include "xmode_stack.h"
#define max(a,b) ((a)>(b)?(a):(b))
XContext desc_context;
-static pointer_dictionary colorname_dict = NULL;
extern int internal_border_width;
extern unsigned long default_bgcolor;
extern unsigned long default_fgcolor;
-extern unsigned long x_string_to_color();
void
-xshowinit()
+xshowinit(void)
{
desc_context = XUniqueContext();
}
char * resclass;
};
-static char *xres_get_resource (restype, style)
- struct res_dict_type *restype;
- char *style;
+static char *
+xres_get_resource(struct res_dict_type *restype,
+ char *style)
{
char *desc;
pointer_dictionary_binding *binding;
};
/*ARGSUSED*/
-char *mode_to_colorname (dpy, style, mode)
- Display *dpy;
- char *style;
- xmode *mode;
+char *
+mode_to_colorname (Display *dpy,
+ char *style,
+ xmode *mode)
{
char *desc, *result;
return result;
}
-void fixup_and_draw(dpy, style, auxblocks, blocks, num, lines, numlines,
- beepcount)
- Display *dpy;
- char *style;
- xblock *blocks;
- xauxblock *auxblocks;
- int num;
- xlinedesc *lines;
- int numlines;
- int beepcount;
+void
+fixup_and_draw(Display *dpy,
+ char *style,
+ xauxblock *auxblocks,
+ xblock *blocks,
+ int num,
+ xlinedesc *lines,
+ int numlines,
+ int beepcount)
{
int gram_xalign = 1;
int gram_yalign = 1;
x_gram *gram;
int strindex = 0;
- int line, block;
+ int line, block=0;
int maxwidth=0, chars=0, maxascent, maxdescent;
int ssize, lsize,csize, rsize, width;
int i, ascent, descent;
/* add up sizes for each block, get max ascent and descent */
- for (i=0, block=lines[line].startblock; i<lines[line].numblock;
- i++,block++) {
+ for (i=0; i<lines[line].numblock; i++,block++) {
chars += auxblocks[block].len;
ssize = XTextWidth(auxblocks[block].font, auxblocks[block].str,
auxblocks[block].len);
ascent = auxblocks[block].font->ascent;
descent = auxblocks[block].font->descent;
if (ascent>maxascent)
- maxascent = ascent;
+ maxascent = ascent;
if (descent>maxdescent)
- maxdescent = descent;
+ maxdescent = descent;
switch (auxblocks[block].align) {
- case LEFTALIGN:
+ case LEFTALIGN:
lsize += ssize;
break;
-
- case CENTERALIGN:
+
+ case CENTERALIGN:
csize += ssize;
break;
-
- case RIGHTALIGN:
+
+ case RIGHTALIGN:
rsize += ssize;
break;
}
/* set x1,y1,x2,y2 of each block also. */
gram->text = (char *)malloc(chars);
+ block = 0;
for (line=0; line<numlines; line++) {
lofs = internal_border_width;
yend = yofs+lines[line].descent+1; /* +1 because lines look scrunched
without it. */
- for (i=0, block=lines[line].startblock; i<lines[line].numblock;
- i++,block++) {
+ for (i=0; i<lines[line].numblock; i++,block++) {
blocks[block].fid = auxblocks[block].font->fid;
switch (auxblocks[block].align) {
case LEFTALIGN:
strindex += blocks[block].strlen;
}
- blocks[block].fid = block?blocks[block-1].fid:auxblocks[0].font->fid;
- blocks[block].x = maxwidth + internal_border_width;
- blocks[block].x1 = (lines[line].rsize?rofs:
- (lines[line].csize?cofs:
- lofs));
- blocks[block].x2 = maxwidth + internal_border_width*2;
- blocks[block].y = yofs;
- blocks[block].y1 = ystart;
- blocks[block].y2 = yend;
- blocks[block].strindex = 0;
- blocks[block].strlen = -1; /* magic value indicates newline */
- block++;
-
yofs = yend;
+
}
if ((geometry = var_get_variable("X_geometry")),(geometry[0]=='\0'))
}
/* Silly almost-but-not-quite-useless helper function */
-char *no_dots_downcase_var(str)
- char *str;
+char *
+no_dots_downcase_var(char *str)
{
register char *var, *var2;
#define MODE_TO_FONT(dpy,style,mode) \
get_font((dpy),(style),(mode)->font?(mode)->font:(mode)->substyle, \
(mode)->size, (mode)->bold+(mode)->italic*2)
-void xshow(dpy, desc, numstr, numnl)
- Display *dpy;
- desctype *desc;
- int numstr;
- int numnl;
+void
+xshow(Display *dpy,
+ desctype *desc,
+ int numstr,
+ int numnl)
{
XFontStruct *font;
xmode_stack modes = xmode_stack_create();
lines = (xlinedesc *)malloc(sizeof(xlinedesc)*(numnl+1));
- blocks = (xblock *)malloc(sizeof(xblock)*(numstr+numnl+1));
- auxblocks = (xauxblock *)malloc(sizeof(xauxblock)*(numstr+numnl+1));
+ blocks = (xblock *)malloc(sizeof(xblock)*numstr);
+ auxblocks = (xauxblock *)malloc(sizeof(xauxblock)*numstr);
curmode.bold = 0;
curmode.italic = 0;
break;
case DT_NL:
- font = MODE_TO_FONT(dpy,style,&curmode);
-
- auxblocks[nextblock].len = -1;
- auxblocks[nextblock].font = font;
- if (curmode.expcolor)
- blocks[nextblock].fgcolor = curmode.color;
- else
- blocks[nextblock].fgcolor =
- x_string_to_color(mode_to_colorname(dpy,style,&curmode),
- default_fgcolor);
- nextblock++;
-
lines[line].startblock = linestart;
- lines[line].numblock = (nextblock-linestart)-1;
+ lines[line].numblock = nextblock-linestart;
+ font = MODE_TO_FONT(dpy,style,&curmode);
lines[line].ascent = font->ascent;
lines[line].descent = font->descent;
line++;
-
linestart = nextblock;
break;
}
/* case DT_EOF: will drop through to here. */
if (linestart != nextblock) {
- font = MODE_TO_FONT(dpy,style,&curmode);
- auxblocks[nextblock].len = -1;
- auxblocks[nextblock].font = font;
- if (curmode.expcolor)
- blocks[nextblock].fgcolor = curmode.color;
- else
- blocks[nextblock].fgcolor =
- x_string_to_color(mode_to_colorname(dpy,style,&curmode),
- default_fgcolor);
- nextblock++;
-
lines[line].startblock = linestart;
- lines[line].numblock = (nextblock-linestart)-1;
+ lines[line].numblock = nextblock-linestart;
+ font = MODE_TO_FONT(dpy,style,&curmode);
lines[line].ascent = 0;
lines[line].descent = 0;
line++;
free(style);
}
-static void xhandleevent(dpy, w, event)
- Display *dpy;
- Window w;
- XEvent *event;
+static void
+xhandleevent(Display *dpy,
+ Window w,
+ XEvent *event)
{
x_gram *gram;
XFlush(dpy);
}
-void x_get_input(dpy)
- Display *dpy;
+void
+x_get_input(Display *dpy)
{
XEvent event;