v04i044: xdvi, Patch4
Dan Heller
argv at island.uu.net
Mon Jul 17 16:27:26 AEST 1989
Submitted-by: vojta at bosco.Berkeley.EDU
Posting-number: Volume 4, Issue 44
Archive-name: xdvi/patch4
Here's patch 4 to xdvi. This patch allows the magnifying glass to move.
It's jerky, but better than nothing. Also, it changes the default shrink
factor to 3. I find it more useful than 4.
--Paul Vojta, vojta at math.berkeley.edu
---- cut here ----
diff -cr old/Makefile new/Makefile
*** old/Makefile Thu Jul 13 12:52:07 1989
--- new/Makefile Thu Jul 13 12:58:03 1989
***************
*** 22,28 ****
BINDIR=/usr/sipb/$$(MACHTYPE)bin
INCLUDES=-I$(INCDIR)
CFLAGS=-O $(INCLUDES) $(DEFINES)
! LIBS=-L$(LIBDIR) -lXaw -lXt $(XMULIB) -lX11 -lm
SRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c tpic.c \
xdvi.h dvi.h xdvi.icon
OBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o tpic.o
--- 22,28 ----
BINDIR=/usr/sipb/$$(MACHTYPE)bin
INCLUDES=-I$(INCDIR)
CFLAGS=-O $(INCLUDES) $(DEFINES)
! LIBS=-L$(LIBDIR) -lXaw $(XMULIB) -lXt -lX11 -lm
SRCS=xdvi.c dvi_init.c dvi_draw.c $(FONTFORMATS_C) pxl_open.c tpic.c \
xdvi.h dvi.h xdvi.icon
OBJS=xdvi.o dvi_init.o dvi_draw.o $(FONTFORMATS_O) pxl_open.o tpic.o
diff -cr old/README new/README
*** old/README Thu Jul 13 12:52:13 1989
--- new/README Sat Jul 8 15:43:09 1989
***************
*** 61,68 ****
time xdvi -d 8 file.dvi
BMLONG (X11 only; xdvi.c dvi_draw.c gf.c pk.c pxl.c) Store
bitmaps in long integers instead of bytes.
- MAXCHARS (dvi_init.c dvi_draw.c gf.c pk.c pxl.c) Set to 256 for
- 256-character fonts. Default is 128.
ALTFONT Default font to use if the font named in the dvi file
cannot be found. Can be set to NULL. By default, it
is "cmr10".
--- 61,66 ----
***************
*** 125,130 ****
--- 123,131 ----
generating table.h.
-- Patchlevel 3: --
13. Added -altfont command line option and SYSV compilation option.
+ -- Patchlevel 4: --
+ 14. Removed MAXCHARS compilation option. It's automatic now. Made X10
+ scrolling smoother. Implemented the moving magnifying glass.
Paul Vojta, vojta at math.berkeley.edu
================================================================================
diff -cr old/dvi_draw.c new/dvi_draw.c
*** old/dvi_draw.c Thu Jul 13 12:52:19 1989
--- new/dvi_draw.c Sat Jul 8 15:20:40 1989
***************
*** 19,25 ****
* MSBITFIRST store bitmaps internally in with significant bit first
* BMSHORT store bitmaps in shorts instead of bytes
* BMLONG store bitmaps in longs instead of bytes
- * MAXCHARS set to 256 for 256 character fonts (default = 128)
*/
#include <stdio.h>
--- 19,24 ----
***************
*** 294,302 ****
{
register struct glyph *g;
! g = ¤t_font->glyph[ch];
! if (g->bitmap.bits == NULL) {
! if (g->addr == NULL)
oops("Character %d not defined in font %s\n", ch,
current_font->fontname);
open_pxl_file(current_font);
--- 293,301 ----
{
register struct glyph *g;
! if (ch > maxchar ||
! (g = ¤t_font->glyph[ch])->bitmap.bits == NULL) {
! if (ch > maxchar || g->addr == 0)
oops("Character %d not defined in font %s\n", ch,
current_font->fontname);
open_pxl_file(current_font);
***************
*** 378,383 ****
--- 377,383 ----
*prev = fontp->next;
fontp->next = current_font;
current_font = fontp;
+ maxchar = current_font->maxchar;
}
static
***************
*** 426,435 ****
case SET1:
case PUT1:
ch1 = one(dvi_file);
- #if MAXCHARS < 256
- if (ch1 >= MAXCHARS)
- oops("Character code too large: %d", ch1);
- #endif MAXCHARS
set_char(ch1);
if (ch == SET1)
DVI_H += current_font->glyph[ch1].dvi_adv;
--- 426,431 ----
diff -cr old/dvi_init.c new/dvi_init.c
*** old/dvi_init.c Thu Jul 13 12:52:22 1989
--- new/dvi_init.c Mon Jul 10 13:27:43 1989
***************
*** 19,25 ****
* MSBITFIRST store bitmaps internally in with significant bit first
* BMSHORT store bitmaps in shorts instead of bytes
* BMLONG store bitmaps in longs instead of bytes
- * MAXCHARS set to 256 for 256 character fonts (default = 128)
*/
#include <stdio.h>
--- 19,24 ----
***************
*** 29,34 ****
--- 28,34 ----
#include <sys/stat.h>
#define dvi_oops(str) longjmp(dvi_env, (int) str);
+ #define XtOffset(type, field) ((unsigned int)&(((type)NULL)->field))
extern char *alt_font;
static struct stat fstatbuf; /* mechanism to see if file was */
***************
*** 35,40 ****
--- 35,41 ----
time_t dvi_time; /* modified since last usage */
struct font *current_font = NULL; /* ptr into linked list of fonts */
+ ubyte maxchar;
static Boolean font_not_found;
static struct font **old_fonts; /* used by read_postamble */
***************
*** 41,46 ****
--- 42,49 ----
int n_fonts_left = 32767; /* for LRU management of fonts */
+ char *realloc();
+
/*
* DVI preamble and postamble information.
*/
***************
*** 66,72 ****
#ifndef SYSV
char *sprintf();
#endif
! char *malloc();
FILE *pxl_open();
static Boolean
--- 69,75 ----
#ifndef SYSV
char *sprintf();
#endif
! char *malloc(), *strcpy();
FILE *pxl_open();
static Boolean
***************
*** 159,164 ****
--- 162,168 ----
for (;;) {
fontp1 = *fontpp;
if (fontp1 == NULL) {
+ maxchar = 255;
if (!define_new_font(fontp, fontp->fontname)) {
if (alt_font == NULL || !define_new_font(fontp, alt_font)) {
font_not_found = True;
***************
*** 171,176 ****
--- 175,186 ----
fontp->fontname = malloc((unsigned) strlen(alt_font)+1);
(void) strcpy(fontp->fontname, alt_font);
}
+ while (maxchar > 0 && fontp->glyph[maxchar].addr == 0)
+ --maxchar;
+ if (maxchar < 255)
+ fontp = (struct font *) realloc((char *) fontp,
+ XtOffset(struct font *, glyph[(int) maxchar + 1]));
+ fontp->maxchar = maxchar;
break;
}
if (strcmp(fontp->fontname, fontp1->fontname) == 0
***************
*** 294,300 ****
}
free(fontp->fontname);
free(fontp->filename);
! for (g = &fontp->glyph[0]; g < &fontp->glyph[MAXCHARS]; ++g) {
if (g->bitmap.bits) free(g->bitmap.bits);
if (g->bitmap2.bits) free(g->bitmap2.bits);
}
--- 304,311 ----
}
free(fontp->fontname);
free(fontp->filename);
! for (g = fontp->glyph; g <= fontp->glyph + fontp->maxchar; ++g)
! {
if (g->bitmap.bits) free(g->bitmap.bits);
if (g->bitmap2.bits) free(g->bitmap2.bits);
}
***************
*** 394,400 ****
register struct glyph *g;
for (f = current_font; f != NULL; f = f->next)
! for (g = &f->glyph[0]; g < &f->glyph[MAXCHARS]; ++g)
if (g->bitmap2.bits) {
free(g->bitmap2.bits);
g->bitmap2.bits = NULL;
--- 405,411 ----
register struct glyph *g;
for (f = current_font; f != NULL; f = f->next)
! for (g = f->glyph; g <= f->glyph + f->maxchar; ++g)
if (g->bitmap2.bits) {
free(g->bitmap2.bits);
g->bitmap2.bits = NULL;
diff -cr old/gf.c new/gf.c
*** old/gf.c Thu Jul 13 12:52:25 1989
--- new/gf.c Sat Jul 8 15:21:34 1989
***************
*** 76,82 ****
*/
if (debug & DBG_PK)
Printf("Reading header for GF pixel file %s\n", fontp->filename);
- GF_file = fontp->file;
expect(PRE);
expect(GF_ID_BYTE);
/*
--- 76,81 ----
***************
*** 96,116 ****
* Read postamble.
*/
expect(POST);
! (void) four(GF_file); /* pointer to last eoc + 1 */
! (void) four(fontp->file); /* skip design size */
! (void) four(fontp->file); /* skip checksum */
! hppp = sfour(fontp->file);
! vppp = sfour(fontp->file);
if (debug && hppp != vppp)
oops("Warning: aspect ratio not 1:1 for font %s", fontp->fontname);
! (void) four(fontp->file); /* skip min_m */
! (void) four(fontp->file); /* skip max_m */
! (void) four(fontp->file); /* skip min_n */
! (void) four(fontp->file); /* skip max_n */
/*
* Prepare glyph array.
*/
! for (g = fontp->glyph; g < &fontp->glyph[MAXCHARS]; ++g) {
g->addr = 0;
g->bitmap.bits = NULL;
g->bitmap2.bits = NULL;
--- 95,115 ----
* Read postamble.
*/
expect(POST);
! (void) four(GF_file); /* pointer to last eoc + 1 */
! (void) four(GF_file); /* skip design size */
! (void) four(GF_file); /* skip checksum */
! hppp = sfour(GF_file);
! vppp = sfour(GF_file);
if (debug && hppp != vppp)
oops("Warning: aspect ratio not 1:1 for font %s", fontp->fontname);
! (void) four(GF_file); /* skip min_m */
! (void) four(GF_file); /* skip max_m */
! (void) four(GF_file); /* skip min_n */
! (void) four(GF_file); /* skip max_n */
/*
* Prepare glyph array.
*/
! for (g = fontp->glyph; g < fontp->glyph + 256; ++g) {
g->addr = 0;
g->bitmap.bits = NULL;
g->bitmap2.bits = NULL;
***************
*** 123,133 ****
int addr;
ch = one(GF_file); /* character code */
- #if MAXCHARS < 256
- if (ch >= MAXCHARS)
- oops("Character code %d outside range, file %s", ch,
- fontp->fontname);
- #endif MAXCHARS
g = &fontp->glyph[ch];
switch (cmnd) {
case CHAR_LOC:
--- 122,127 ----
diff -cr old/patchlevel.h new/patchlevel.h
*** old/patchlevel.h Thu Jul 13 12:52:26 1989
--- new/patchlevel.h Sat Jul 8 15:43:22 1989
***************
*** 1 ****
! #define PATCHLEVEL 3
--- 1 ----
! #define PATCHLEVEL 4
diff -cr old/pk.c new/pk.c
*** old/pk.c Thu Jul 13 12:52:29 1989
--- new/pk.c Sat Jul 8 15:22:10 1989
***************
*** 29,40 ****
static int
PK_get_nyb( fp )
! register struct font *fp;
{
unsigned temp;
if( PK_bitpos < 0 )
{
! PK_input_byte = one(fp->file);
PK_bitpos = 4;
}
temp = PK_input_byte >> PK_bitpos;
--- 29,40 ----
static int
PK_get_nyb( fp )
! register FILE *fp;
{
unsigned temp;
if( PK_bitpos < 0 )
{
! PK_input_byte = one(fp);
PK_bitpos = 4;
}
temp = PK_input_byte >> PK_bitpos;
***************
*** 45,51 ****
static int
PK_packed_num( fp )
! register struct font *fp;
{
int i,j;
if( ( i = PK_get_nyb( fp ) ) == 0 )
--- 45,51 ----
static int
PK_packed_num( fp )
! register FILE *fp;
{
int i,j;
if( ( i = PK_get_nyb( fp ) ) == 0 )
***************
*** 76,88 ****
static void
! PK_skip_specials( fp )
! register struct font *fp;
{
int i,j;
do
{
! PK_flag_byte = one(fp->file);
if( PK_flag_byte >= PK_CMD_START )
{
switch( PK_flag_byte )
--- 76,89 ----
static void
! PK_skip_specials(fontp)
! register struct font *fontp;
{
int i,j;
+ register FILE *fp = fontp->file;
do
{
! PK_flag_byte = one(fp);
if( PK_flag_byte >= PK_CMD_START )
{
switch( PK_flag_byte )
***************
*** 94,110 ****
{
i = 0;
for (j = PK_CMD_START; j <= PK_flag_byte; j++)
! i = (i*256) + one(fp->file);
! while (i--) (void) one(fp->file);
break;
}
case PK_Y :
! (void) four(fp->file);
case PK_POST :
case PK_NOOP :
break;
default :
! oops("Unexpected %d in PK file %s\n", PK_flag_byte, fp->fontname);
break;
}
}
--- 95,112 ----
{
i = 0;
for (j = PK_CMD_START; j <= PK_flag_byte; j++)
! i = (i*256) + one(fp);
! while (i--) (void) one(fp);
break;
}
case PK_Y :
! (void) four(fp);
case PK_POST :
case PK_NOOP :
break;
default :
! oops("Unexpected %d in PK file %s\n", PK_flag_byte,
! fontp->fontname);
break;
}
}
***************
*** 147,153 ****
/*if (fontp->f_scale == 0) fontp->f_scale = 1000;*/
{
register struct glyph *g;
! for (g = fontp->glyph; g < &fontp->glyph[MAXCHARS]; ++g) {
g->addr = 0;
g->bitmap.bits = NULL;
g->bitmap2.bits = NULL;
--- 149,155 ----
/*if (fontp->f_scale == 0) fontp->f_scale = 1000;*/
{
register struct glyph *g;
! for (g = fontp->glyph; g < fontp->glyph + 256; ++g) {
g->addr = 0;
g->bitmap.bits = NULL;
g->bitmap2.bits = NULL;
***************
*** 173,183 ****
bytes_left = (flag_low_bits << 8) + one(fontp->file);
cc = one(fontp->file);
}
- #if MAXCHARS < 256
- if (cc >= MAXCHARS)
- oops("Character code %d outside range, file %s\n", cc,
- fontp->fontname);
- #endif MAXCHARS
fontp->glyph[cc].addr = ftell(fontp->file);
fontp->glyph[cc].x2 = PK_flag_byte;
Fseek(fontp->file, (long) bytes_left, 1);
--- 175,180 ----
***************
*** 185,192 ****
}
static void
! read_char(fp, ch)
! register struct font *fp;
ubyte ch;
{
int i, j;
--- 182,189 ----
}
static void
! read_char(fontp, ch)
! register struct font *fontp;
ubyte ch;
{
int i, j;
***************
*** 195,206 ****
Boolean paint_switch;
BMUNIT *cp;
register struct glyph *g;
long fpwidth;
BMUNIT word;
int word_weight, bytes_wide;
int rows_left, h_bit, count;
! g = &fp->glyph[ch];
PK_flag_byte = g->x2;
PK_dyn_f = PK_flag_byte >> 4;
paint_switch = ((PK_flag_byte & 8) != 0);
--- 192,204 ----
Boolean paint_switch;
BMUNIT *cp;
register struct glyph *g;
+ register FILE *fp = fontp->file;
long fpwidth;
BMUNIT word;
int word_weight, bytes_wide;
int rows_left, h_bit, count;
! g = &fontp->glyph[ch];
PK_flag_byte = g->x2;
PK_dyn_f = PK_flag_byte >> 4;
paint_switch = ((PK_flag_byte & 8) != 0);
***************
*** 214,238 ****
/* now read rest of character preamble */
! if (n != 4) fpwidth = snum(fp->file, 3);
else {
! fpwidth = sfour(fp->file);
! (void) four(fp->file); /* horizontal escapement */
}
! (void) num(fp->file, n); /* vertical escapement */
{
unsigned long w, h;
! w = num(fp->file, n);
! h = num(fp->file, n);
if (w > 0x7fff || h > 0x7fff)
! oops("Too large character (%d) in file %s\n", ch, fp->fontname);
g->bitmap.w = w;
g->bitmap.h = h;
}
! g->x = snum(fp->file, n);
! g->y = snum(fp->file, n);
! g->dvi_adv = ((double) fp->scale * fpwidth) / (1 << 20);
if (debug & DBG_PK) {
if (g->bitmap.w != 0)
--- 212,237 ----
/* now read rest of character preamble */
! if (n != 4) fpwidth = snum(fp, 3);
else {
! fpwidth = sfour(fp);
! (void) four(fp); /* horizontal escapement */
}
! (void) num(fp, n); /* vertical escapement */
{
unsigned long w, h;
!
! w = num(fp, n);
! h = num(fp, n);
if (w > 0x7fff || h > 0x7fff)
! oops("Too large character (%d) in file %s\n", ch, fontp->fontname);
g->bitmap.w = w;
g->bitmap.h = h;
}
! g->x = snum(fp, n);
! g->y = snum(fp, n);
! g->dvi_adv = ((double) fontp->scale * fpwidth) / (1 << 20);
if (debug & DBG_PK) {
if (g->bitmap.w != 0)
***************
*** 242,248 ****
}
if (g->bitmap.w == 0) return;
! alloc_bitmap(&g->bitmap, fp->fontname, ch);
cp = (BMUNIT *) g->bitmap.bits;
/*
* read character data into *cp
--- 241,247 ----
}
if (g->bitmap.w == 0) return;
! alloc_bitmap(&g->bitmap, fontp->fontname, ch);
cp = (BMUNIT *) g->bitmap.bits;
/*
* read character data into *cp
***************
*** 264,270 ****
{
if (--PK_bitpos < 0)
{
! word = one(fp->file);
PK_bitpos = 7;
}
#ifndef MSBITFIRST
--- 263,269 ----
{
if (--PK_bitpos < 0)
{
! word = one(fp);
PK_bitpos = 7;
}
#ifndef MSBITFIRST
***************
*** 357,364 ****
}
if (cp != ((BMUNIT *) (g->bitmap.bits + bytes_wide * g->bitmap.h)))
oops("Wrong number of bits stored: char. %d, font %s\n", ch,
! fp->fontname);
if (rows_left != 0 || h_bit != g->bitmap.w)
! oops("Bad pk file (%s), too many bits\n", fp->fontname);
}
}
--- 356,363 ----
}
if (cp != ((BMUNIT *) (g->bitmap.bits + bytes_wide * g->bitmap.h)))
oops("Wrong number of bits stored: char. %d, font %s\n", ch,
! fontp->fontname);
if (rows_left != 0 || h_bit != g->bitmap.w)
! oops("Bad pk file (%s), too many bits\n", fontp->fontname);
}
}
diff -cr old/pxl.c new/pxl.c
*** old/pxl.c Thu Jul 13 12:52:31 1989
--- new/pxl.c Sat Jul 8 15:23:15 1989
***************
*** 56,85 ****
register struct font *fontp;
{
register struct glyph *g;
long font_dir_ptr;
if (debug & DBG_PK)
Printf("Reading header for PXL file %s\n", fontp->filename);
fontp->read_char = read_char;
! if (four(fontp->file) != 1001)
oops("File %s has wrong PXL magic number.\n", fontp->filename);
/* seek to trailer info */
! Fseek(fontp->file, (long) -5 * 4, 2);
! (void) four(fontp->file); /* checksum */
! (void) four(fontp->file); /* magnify */
! (void) four(fontp->file); /* design size */
! font_dir_ptr = sfour(fontp->file) * 4;
! (void) four(fontp->file); /* pxl id word */
/* seek to font directory */
! Fseek(fontp->file, font_dir_ptr, 0);
! for (g = fontp->glyph; g < &fontp->glyph[128]; ++g) {
g->bitmap.bits = NULL;
g->bitmap2.bits = NULL;
! g->bitmap.w = two(fontp->file);
! g->bitmap.h = two(fontp->file);
! g->x = stwo(fontp->file);
! g->y = stwo(fontp->file);
! g->addr = four(fontp->file) * 4;
/*
** The TFM-width word is kind of funny in the units
** it is expressed in. It works this way:
--- 56,86 ----
register struct font *fontp;
{
register struct glyph *g;
+ register FILE *fp;
long font_dir_ptr;
if (debug & DBG_PK)
Printf("Reading header for PXL file %s\n", fontp->filename);
fontp->read_char = read_char;
! if (four(fp = fontp->file) != 1001)
oops("File %s has wrong PXL magic number.\n", fontp->filename);
/* seek to trailer info */
! Fseek(fp, (long) -5 * 4, 2);
! (void) four(fp); /* checksum */
! (void) four(fp); /* magnify */
! (void) four(fp); /* design size */
! font_dir_ptr = sfour(fp) * 4;
! (void) four(fp); /* pxl id word */
/* seek to font directory */
! Fseek(fp, font_dir_ptr, 0);
! for (g = fontp->glyph; g < fontp->glyph + 128; ++g) {
g->bitmap.bits = NULL;
g->bitmap2.bits = NULL;
! g->bitmap.w = two(fp);
! g->bitmap.h = two(fp);
! g->x = stwo(fp);
! g->y = stwo(fp);
! g->addr = four(fp) * 4;
/*
** The TFM-width word is kind of funny in the units
** it is expressed in. It works this way:
***************
*** 110,127 ****
*/
g->dvi_adv =
! ((double) fontp->scale * four(fontp->file)) / (1 << 20);
if (debug & DBG_PK)
Printf("size=%dx%d, dvi_adv=%d\n", g->bitmap.w, g->bitmap.h,
g->dvi_adv);
}
! #if MAXCHARS > 128
! for ( ; g < &fontp->glyph[MAXCHARS]; ++g) {
! g->bitmap.bits = NULL;
! g->bitmap2.bits = NULL;
! g->addr = 0;
! }
! #endif MAXCHARS
}
static void
--- 111,122 ----
*/
g->dvi_adv =
! ((double) fontp->scale * four(fp)) / (1 << 20);
if (debug & DBG_PK)
Printf("size=%dx%d, dvi_adv=%d\n", g->bitmap.w, g->bitmap.h,
g->dvi_adv);
}
! maxchar = 127;
}
static void
***************
*** 131,136 ****
--- 126,132 ----
{
register struct bitmap *bitmap;
register BMUNIT *ptr;
+ register FILE *fp = fontp->file;
register int i, j;
#ifndef BMLONG
register int padding_length;
***************
*** 146,174 ****
for (i = bitmap->h; i > 0; --i) {
for (j = bitmap->bytes_wide; j > 0; j -= BYTES_PER_BMUNIT) {
#ifndef MSBITFIRST
! *ptr = _reverse_byte[one(fontp->file)];
#if BYTES_PER_BMUNIT > 1
! *ptr |= _reverse_byte[one(fontp->file)] << 8;
#endif
#ifdef BMLONG
! *ptr |= _reverse_byte[one(fontp->file)] << 16;
! *ptr |= _reverse_byte[one(fontp->file)] << 24;
#endif BMLONG
#else MSBITFIRST
*ptr = 0;
#ifdef BMLONG
! *ptr |= one(fontp->file) << 24;
! *ptr |= one(fontp->file) << 16;
#endif BMLONG
#if BYTES_PER_BMUNIT > 1
! *ptr |= one(fontp->file) << 8;
#endif
! *ptr |= one(fontp->file);
#endif MSBITFIRST
++ptr;
}
#ifndef BMLONG
! for (j = padding_length; j > 0; --j) (void) one(fontp->file);
#endif BMLONG
}
}
--- 142,170 ----
for (i = bitmap->h; i > 0; --i) {
for (j = bitmap->bytes_wide; j > 0; j -= BYTES_PER_BMUNIT) {
#ifndef MSBITFIRST
! *ptr = _reverse_byte[one(fp)];
#if BYTES_PER_BMUNIT > 1
! *ptr |= _reverse_byte[one(fp)] << 8;
#endif
#ifdef BMLONG
! *ptr |= _reverse_byte[one(fp)] << 16;
! *ptr |= _reverse_byte[one(fp)] << 24;
#endif BMLONG
#else MSBITFIRST
*ptr = 0;
#ifdef BMLONG
! *ptr |= one(fp) << 24;
! *ptr |= one(fp) << 16;
#endif BMLONG
#if BYTES_PER_BMUNIT > 1
! *ptr |= one(fp) << 8;
#endif
! *ptr |= one(fp);
#endif MSBITFIRST
++ptr;
}
#ifndef BMLONG
! for (j = padding_length; j > 0; --j) (void) one(fp);
#endif BMLONG
}
}
diff -cr old/xdvi.c new/xdvi.c
*** old/xdvi.c Thu Jul 13 12:52:43 1989
--- new/xdvi.c Thu Jul 13 13:07:32 1989
***************
*** 19,25 ****
* MSBITFIRST store bitmaps internally in with significant bit first
* BMSHORT store bitmaps in shorts instead of bytes
* BMLONG store bitmaps in longs instead of bytes
- * MAXCHARS set to 256 for 256 character fonts (default = 128)
* ALTFONT default for -altfont option.
*/
#ifndef lint
--- 19,24 ----
***************
*** 50,56 ****
#endif not OLD_X11_TOOLKIT
#include <X11/Shell.h> /* needed for def. of XtNiconX */
#include <X11/Viewport.h>
- #include <X11/Simple.h>
#include <X11/cursorfont.h>
#include "xdvi.icon"
--- 49,54 ----
***************
*** 72,80 ****
static Screen *SCRN;
static Cursor redraw_cursor, ready_cursor;
#define SetCursor(x) XDefineCursor(DISP, mane.win, x)
! #define ClearPage() XClearWindow(DISP, mane.win);
#define Flush() XFlush(DISP)
! static Boolean unmapped = True;
#ifndef X11HEIGHT
#define X11HEIGHT 8 /* Height of server default font */
#endif X11HEIGHT
--- 70,82 ----
static Screen *SCRN;
static Cursor redraw_cursor, ready_cursor;
#define SetCursor(x) XDefineCursor(DISP, mane.win, x)
! #define ClearPage(wr) XClearWindow(DISP, (wr).win);
! #define ClearArea(win, x, y, w, h) XClearArea(DISP, win, x, y, w, h, False)
! #define CopyArea(win, x, y, w, h, x2, y2) \
! XCopyArea(DISP, win, win, DefaultGCOfScreen(SCRN), \
! x, y, w, h, x2, y2)
#define Flush() XFlush(DISP)
! static Boolean resized = False;
#ifndef X11HEIGHT
#define X11HEIGHT 8 /* Height of server default font */
#endif X11HEIGHT
***************
*** 86,92 ****
typedef int Position;
typedef int Dimension;
#define SetCursor(x)
! #define ClearPage() XClear(mane.win);
#define XBell(a,b) XFeep(b/10-1)
#define Flush() XFlush()
#define ConnectionNumber(DISP) (_XlibCurrentDisplay->fd)
--- 88,97 ----
typedef int Position;
typedef int Dimension;
#define SetCursor(x)
! #define ClearPage(wr) XClear((wr).win);
! #define ClearArea(win, x, y, w, h) XPixSet(win, x, y, w, h, backpix)
! #define CopyArea(win, x, y, w, h, x2, y2) \
! XCopyArea(win, x, y, x2, y2, w, h, GXcopy);
#define XBell(a,b) XFeep(b/10-1)
#define Flush() XFlush()
#define ConnectionNumber(DISP) (_XlibCurrentDisplay->fd)
***************
*** 143,156 ****
int page_w, page_h;
static int screen_w, screen_h;
static Dimension window_w, window_h;
static int home_x, home_y;
static int min_x, max_x, min_y, max_y;
! struct WindowRec mane = {NULL, 4, 0, 0, MAXINT, 0, MAXINT, 0};
! struct WindowRec alt = {NULL, 1, 0, 0, MAXINT, 0, MAXINT, 0};
/* curr is temporary storage except for within redraw() */
! struct WindowRec curr = {NULL, 4, 0, 0, MAXINT, 0, MAXINT, 0};
/*
* Mechanism to keep track of the magnifier window. The problems are,
--- 148,173 ----
int page_w, page_h;
static int screen_w, screen_h;
+ #define clip_w mane.width
+ #define clip_h mane.height
+ #ifndef X10
static Dimension window_w, window_h;
+ static Position main_x, main_y;
+ #else X10
+ #define window_w clip_w
+ #define window_h clip_h
+ #define main_x 0
+ #define main_y 0
+ #endif X10
+ static Position mag_x, mag_y, new_mag_x, new_mag_y;
+ static Boolean mag_moved = False;
static int home_x, home_y;
static int min_x, max_x, min_y, max_y;
! struct WindowRec mane = {NULL, 3, 0, 0, 0, 0, MAXDIM, 0, MAXDIM, 0};
! struct WindowRec alt = {NULL, 1, 0, 0, 0, 0, MAXDIM, 0, MAXDIM, 0};
/* curr is temporary storage except for within redraw() */
! struct WindowRec curr = {NULL, 3, 0, 0, 0, 0, MAXDIM, 0, MAXDIM, 0};
/*
* Mechanism to keep track of the magnifier window. The problems are,
***************
*** 259,264 ****
--- 276,282 ----
#ifndef X10
static Widget top_level, vport_widget, draw_widget, clip_widget;
+ static Widget x_bar, y_bar; /* horizontal and vertical scroll bars */
static XImage *image;
static Arg vport_args[] = {
***************
*** 289,295 ****
#ifdef lint
#ifndef X10
! WidgetClass viewportWidgetClass, simpleWidgetClass;
char xdvi_bits[288];
#else X10
short xdvi_bits[15], xdvi_mask_bits[15];
--- 307,313 ----
#ifdef lint
#ifndef X10
! WidgetClass viewportWidgetClass, widgetClass;
char xdvi_bits[288];
#else X10
short xdvi_bits[15], xdvi_mask_bits[15];
***************
*** 323,329 ****
{
if (debug & DBG_BITMAP)
! Printf("X(%d,%d)\n", x-curr.base_x, y-curr.base_y);
if (x < max_x && x + bitmap->w >= min_x &&
y < max_y && y + bitmap->h >= min_y) {
if (--event_counter == 0) read_events(False);
--- 341,347 ----
{
if (debug & DBG_BITMAP)
! Printf("X(%d,%d)\n", x - curr.base_x, y - curr.base_y);
if (x < max_x && x + bitmap->w >= min_x &&
y < max_y && y + bitmap->h >= min_y) {
if (--event_counter == 0) read_events(False);
***************
*** 358,363 ****
--- 376,461 ----
put_rectangle(x + w - t, y, t, h, True);
}
+ /*
+ * Event-handling routines
+ */
+
+ static void
+ expose(windowrec, x, y, w, h)
+ register struct WindowRec *windowrec;
+ int x, y, w, h;
+ {
+ if (windowrec->min_x > x) windowrec->min_x = x;
+ if (windowrec->max_x < x + w)
+ windowrec->max_x = x + w;
+ if (windowrec->min_y > y) windowrec->min_y = y;
+ if (windowrec->max_y < y + h)
+ windowrec->max_y = y + h;
+ }
+
+ static void
+ clearexpose(windowrec, x, y, w, h)
+ struct WindowRec *windowrec;
+ int x, y, w, h;
+ {
+ ClearArea(windowrec->win, x, y, w, h);
+ expose(windowrec, x, y, w, h);
+ }
+
+ static void
+ scrollwindow(windowrec, x0, y0)
+ register struct WindowRec *windowrec;
+ int x0, y0;
+ {
+ int x, y;
+ int x2 = 0, y2 = 0;
+ int ww, hh;
+
+ x = x0 - windowrec->base_x;
+ y = y0 - windowrec->base_y;
+ ww = windowrec->width - x;
+ hh = windowrec->height - y;
+ windowrec->base_x = x0;
+ windowrec->base_y = y0;
+ if (curr.win == windowrec->win) {
+ curr.base_x = x0;
+ curr.base_y = y0;
+ }
+ windowrec->min_x -= x;
+ if (windowrec->min_x < 0) windowrec->min_x = 0;
+ windowrec->max_x -= x;
+ if (windowrec->max_x > windowrec->width)
+ windowrec->max_x = windowrec->width;
+ windowrec->min_y -= y;
+ if (windowrec->min_y < 0) windowrec->min_y = 0;
+ windowrec->max_y -= y;
+ if (windowrec->max_y > windowrec->height)
+ windowrec->max_y = windowrec->height;
+ if (x < 0) {
+ x2 = -x;
+ x = 0;
+ ww = windowrec->width - x2;
+ }
+ if (y < 0) {
+ y2 = -y;
+ y = 0;
+ hh = windowrec->height - y2;
+ }
+ if (ww <= 0 || hh <= 0) {
+ ClearPage(*windowrec);
+ windowrec->min_x = windowrec->min_y = 0;
+ windowrec->max_x = windowrec->width;
+ windowrec->max_y = windowrec->height;
+ }
+ else {
+ CopyArea(windowrec->win, x, y, ww, hh, x2, y2);
+ if (x > 0) clearexpose(windowrec, ww, 0, x, windowrec->height);
+ if (x2 > 0) clearexpose(windowrec, 0, 0, x2, windowrec->height);
+ if (y > 0) clearexpose(windowrec, 0, hh, windowrec->width, y);
+ if (y2 > 0) clearexpose(windowrec, 0, 0, windowrec->width, y2);
+ }
+ }
+
#ifndef X10
/*
* routines for X11 toolkit
***************
*** 368,374 ****
{XtNheight, (XtArgVal) &window_h},
};
! #define get_wh(widget) XtGetValues(widget, arg_wh, 2)
static Position window_x, window_y;
static Arg arg_xy[] = {
--- 466,475 ----
{XtNheight, (XtArgVal) &window_h},
};
! static Arg arg_wh_clip[] = {
! {XtNwidth, (XtArgVal) &clip_w},
! {XtNheight, (XtArgVal) &clip_h},
! };
static Position window_x, window_y;
static Arg arg_xy[] = {
***************
*** 381,461 ****
#define mane_base_x 0
#define mane_base_y 0
! static Boolean
! scroll(horizontal, percent)
! Boolean horizontal;
! float percent;
! {
! register Widget widget;
!
! widget = XtNameToWidget(vport_widget,
! horizontal ? "horizontal" : "vertical");
! if (!widget) return False;
! XtGetValues(clip_widget, horizontal ? &arg_wh[0] : &arg_wh[1], 1);
! XtCallCallbacks(widget, XtNscrollProc,
! (int) (percent*(horizontal ? window_w : window_h)));
! return True;
! }
!
! /*
! * We unmap the window so that it does not generate expose events when
! * moving things around. I have found that compress_exposure does not do
! * this.
! */
!
static
! unmap()
{
- if (unmapped) return;
- XUnmapWindow(DISP, mane.win);
- unmapped = True;
- }
-
- static
- home()
- {
- register Widget widget;
register int coord;
- unmap();
get_xy();
! get_wh(clip_widget);
! widget = XtNameToWidget(vport_widget, "horizontal");
! if (widget) {
coord = 0;
! if (page_w > window_w) {
! coord = (page_w - window_w) / 2;
if (coord > home_x / mane.shrinkfactor)
coord = home_x / mane.shrinkfactor;
}
! XtCallCallbacks(widget, XtNscrollProc, window_x + coord);
}
! widget = XtNameToWidget(vport_widget, "vertical");
! if (widget) {
coord = 0;
! if (page_h > window_h) {
! coord = (page_h - window_h) / 2;
if (coord > home_y / mane.shrinkfactor)
coord = home_y / mane.shrinkfactor;
}
! XtCallCallbacks(widget, XtNscrollProc, window_y + coord);
}
}
static void
center(x, y)
int x, y;
{
- register Widget widget;
-
/* We use the clip widget here because it gives a more exact value. */
! get_wh(clip_widget);
! x -= window_w/2;
! y -= window_h/2;
! widget = XtNameToWidget(vport_widget, "horizontal");
! if (widget) XtCallCallbacks(widget, XtNscrollProc, x);
! widget = XtNameToWidget(vport_widget, "vertical");
! if (widget) XtCallCallbacks(widget, XtNscrollProc, y);
XWarpPointer(DISP, None, None, 0, 0, 0, 0, -x, -y);
}
--- 482,536 ----
#define mane_base_x 0
#define mane_base_y 0
! #define home(x) Xtk_home()
static
! Xtk_home()
{
register int coord;
get_xy();
! if (x_bar) {
coord = 0;
! if (page_w > clip_w) {
! coord = (page_w - clip_w) / 2;
if (coord > home_x / mane.shrinkfactor)
coord = home_x / mane.shrinkfactor;
}
! XtCallCallbacks(x_bar, XtNscrollProc, window_x + coord);
}
! if (y_bar) {
coord = 0;
! if (page_h > clip_h) {
! coord = (page_h - clip_h) / 2;
if (coord > home_y / mane.shrinkfactor)
coord = home_y / mane.shrinkfactor;
}
! XtCallCallbacks(y_bar, XtNscrollProc, window_y + coord);
}
}
+ static
+ get_geom()
+ {
+ register Dimension old_clip_w = clip_w;
+
+ XtGetValues(vport_widget, arg_wh, 2);
+ XtGetValues(clip_widget, arg_wh_clip, 2);
+ x_bar = XtNameToWidget(vport_widget, "horizontal");
+ y_bar = XtNameToWidget(vport_widget, "vertical");
+ if (old_clip_w == 0) home(False);
+ resized = False;
+ }
+
static void
center(x, y)
int x, y;
{
/* We use the clip widget here because it gives a more exact value. */
! x -= clip_w/2;
! y -= clip_h/2;
! if (x_bar) XtCallCallbacks(x_bar, XtNscrollProc, x);
! if (y_bar) XtCallCallbacks(y_bar, XtNscrollProc, y);
XWarpPointer(DISP, None, None, 0, 0, 0, 0, -x, -y);
}
***************
*** 473,498 ****
{
XBell(DISP, 20);
}
#else X10
! static
! home()
{
! mane.base_x = 0;
! if (page_w > window_w) {
! mane.base_x = (page_w - window_w) / 2;
! if (mane.base_x > home_x / mane.shrinkfactor)
! mane.base_x = home_x / mane.shrinkfactor;
}
! mane.base_y = 0;
! if (page_h > window_h) {
! mane.base_y = (page_h - window_h) / 2;
! if (mane.base_y > home_y / mane.shrinkfactor)
! mane.base_y = home_y / mane.shrinkfactor;
}
}
- #define unmap()
- #define get_wh(widget)
#define get_xy()
#define window_x 0
#define window_y 0
--- 548,593 ----
{
XBell(DISP, 20);
}
+
+ /*ARGSUSED*/
+ static void
+ handle_resize(widget, junk, event)
+ Widget widget;
+ caddr_t junk;
+ XEvent *event;
+ {
+ resized = True;
+ }
+
#else X10
! static void
! home(scrl)
! Boolean scrl;
{
! int x = 0, y = 0;
!
! if (page_w > clip_w) {
! x = (page_w - clip_w) / 2;
! if (x > home_x / mane.shrinkfactor)
! x = home_x / mane.shrinkfactor;
}
! if (page_h > clip_h) {
! y = (page_h - clip_h) / 2;
! if (y > home_y / mane.shrinkfactor)
! y = home_y / mane.shrinkfactor;
}
+ if (scrl)
+ scrollwindow(&mane, x, y);
+ else {
+ mane.base_x = x;
+ mane.base_y = y;
+ if (curr.win == mane.win) {
+ curr.base_x = x;
+ curr.base_y = y;
+ }
+ }
}
#define get_xy()
#define window_x 0
#define window_y 0
***************
*** 500,506 ****
--- 595,629 ----
#define mane_base_y mane.base_y
#endif X10
+ static void
+ compute_mag_pos(xp, yp)
+ int *xp, *yp;
+ {
+ register int t;
+
+ t = mag_x + main_x - alt.width/2;
#ifndef X10
+ if (t > WidthOfScreen(SCRN) - alt.width - 2*MAGBORD)
+ t = WidthOfScreen(SCRN) - alt.width - 2*MAGBORD;
+ #else X10
+ if (t > window_w - alt.width - 2*MAGBORD)
+ t = window_w - alt.width - 2*MAGBORD;
+ #endif X10
+ if (t < 0) t = 0;
+ *xp = t;
+ t = mag_y + main_y - alt.height/2;
+ #ifndef X10
+ if (t > HeightOfScreen(SCRN) - alt.height - 2*MAGBORD)
+ t = HeightOfScreen(SCRN) - alt.height - 2*MAGBORD;
+ #else X10
+ if (t > window_h - alt.height - 2*MAGBORD)
+ t = window_h - alt.height - 2*MAGBORD;
+ #endif X10
+ if (t < 0) t = 0;
+ *yp = t;
+ }
+
+ #ifndef X10
/*ARGSUSED*/
static void
handle_button(widget, junk, event)
***************
*** 509,565 ****
XButtonEvent *event;
#else X10
static void
! handle_button(event, mag_size)
XButtonPressedEvent *event;
- int mag_size;
#endif X10
{
int x, y;
#ifndef X10
- int mag_size = mg_size[event->button - 1];
XSetWindowAttributes attr;
- #endif X10
! if (alt.win != NULL || mane.shrinkfactor == 1 || mag_size <= 0)
XBell(DISP, 20);
else {
#ifndef X10
! x = event->x_root - mag_size/2;
! if (x > WidthOfScreen(SCRN) - mag_size - 2*MAGBORD)
! x = WidthOfScreen(SCRN) - mag_size - 2*MAGBORD;
! if (x < 0) x = 0;
! y = event->y_root - mag_size/2;
! if (y > HeightOfScreen(SCRN) - mag_size - 2*MAGBORD)
! y = HeightOfScreen(SCRN) - mag_size - 2*MAGBORD;
! if (y < 0) y = 0;
! #else X10
! x = event->x - mag_size/2;
! if (x > window_w - mag_size - 2*MAGBORD)
! x = window_w - mag_size - 2*MAGBORD;
! if (x < 0) x = 0;
! y = event->y - mag_size/2;
! if (y > window_h - mag_size - 2*MAGBORD)
! y = window_h - mag_size - 2*MAGBORD;
! if (y < 0) y = 0;
#endif X10
alt.base_x = (event->x + mane_base_x) * mane.shrinkfactor -
! mag_size/2;
alt.base_y = (event->y + mane_base_y) * mane.shrinkfactor -
! mag_size/2;
#ifndef X10
attr.save_under = True;
attr.border_pixel = fore_args.value;
attr.background_pixel = back_args.value;
alt.win = XCreateWindow(DISP, RootWindowOfScreen(SCRN),
! x, y, mag_size, mag_size, MAGBORD,
0, /* depth from parent */
InputOutput, CopyFromParent,
! CWSaveUnder|CWBorderPixel|CWBackPixel, &attr);
! XSetTransientForHint(DISP, alt.win, XtWindow(top_level));
XSelectInput(DISP, alt.win, ExposureMask);
#else X10
alt.win = XCreateWindow(mane.win,
! x, y, mag_size, mag_size, MAGBORD,
bdrmap, backmap);
XSelectInput(alt.win, ExposeRegion);
#endif X10
--- 632,676 ----
XButtonEvent *event;
#else X10
static void
! handle_button(event)
XButtonPressedEvent *event;
#endif X10
{
int x, y;
#ifndef X10
XSetWindowAttributes attr;
! alt.width = alt.height = mg_size[event->button - 1];
! #endif X10
! if (alt.win != NULL || mane.shrinkfactor == 1 || alt.width <= 0)
XBell(DISP, 20);
else {
+ mag_x = event->x;
+ mag_y = event->y;
#ifndef X10
! main_x = event->x_root - mag_x;
! main_y = event->y_root - mag_y;
#endif X10
+ compute_mag_pos(&x, &y);
alt.base_x = (event->x + mane_base_x) * mane.shrinkfactor -
! alt.width/2;
alt.base_y = (event->y + mane_base_y) * mane.shrinkfactor -
! alt.height/2;
#ifndef X10
attr.save_under = True;
attr.border_pixel = fore_args.value;
attr.background_pixel = back_args.value;
+ attr.override_redirect = True;
alt.win = XCreateWindow(DISP, RootWindowOfScreen(SCRN),
! x, y, alt.width, alt.height, MAGBORD,
0, /* depth from parent */
InputOutput, CopyFromParent,
! CWSaveUnder | CWBorderPixel | CWBackPixel |
! CWOverrideRedirect, &attr);
XSelectInput(DISP, alt.win, ExposureMask);
#else X10
alt.win = XCreateWindow(mane.win,
! x, y, alt.width, alt.height, MAGBORD,
bdrmap, backmap);
XSelectInput(alt.win, ExposeRegion);
#endif X10
***************
*** 571,576 ****
--- 682,718 ----
#ifndef X10
/*ARGSUSED*/
static void
+ handle_motion(widget, junk, event)
+ Widget widget;
+ caddr_t junk;
+ XMotionEvent *event;
+ {
+ new_mag_x = event->x;
+ main_x = event->x_root - new_mag_x;
+ new_mag_y = event->y;
+ main_y = event->y_root - new_mag_y;
+ mag_moved = (new_mag_x != mag_x || new_mag_y != mag_y);
+ }
+ #endif X10
+
+ static void
+ movemag(x, y)
+ int x, y;
+ {
+ int xx, yy;
+
+ mag_x = x;
+ mag_y = y;
+ if (mag_x == new_mag_x && mag_y == new_mag_y) mag_moved = False;
+ compute_mag_pos(&xx, &yy);
+ XMoveWindow(DPY alt.win, xx, yy);
+ scrollwindow(&alt, (x + mane_base_x) * mane.shrinkfactor - alt.width/2,
+ (y + mane_base_y) * mane.shrinkfactor - alt.height/2);
+ }
+
+ #ifndef X10
+ /*ARGSUSED*/
+ static void
handle_release(widget, junk, event)
Widget widget;
caddr_t junk;
***************
*** 586,591 ****
--- 728,734 ----
XDestroyWindow(DPY alt.win);
if (curr.win == alt.win) alt_canit = True;
alt.win = NULL;
+ mag_moved = False;
can_exposures(&alt);
}
}
***************
*** 606,617 ****
}
else
alt_stat = 0;
! if (windowrec->min_x > event->x) windowrec->min_x = event->x;
! if (windowrec->max_x < event->x + event->width)
! windowrec->max_x = event->x + event->width;
! if (windowrec->min_y > event->y) windowrec->min_y = event->y;
! if (windowrec->max_y < event->y + event->height)
! windowrec->max_y = event->y + event->height;
}
#endif X10
--- 749,755 ----
}
else
alt_stat = 0;
! expose(windowrec, event->x, event->y, event->width, event->height);
}
#endif X10
***************
*** 643,654 ****
* Also, watch out, if we destroy the magnifying glass while
* writing it.
*/
! if (!XtPending() && (!wait || canit || mane.min_x < MAXINT ||
! alt.min_x < MAXINT))
if (alt_canit) longjmp(canit_env, 1);
else return;
#ifndef X10
XtNextEvent(&event);
if (event.xany.window == alt.win &&
event.type == Expose) {
handle_exp((Widget) NULL, &alt, &event.xexpose);
--- 781,793 ----
* Also, watch out, if we destroy the magnifying glass while
* writing it.
*/
! if (!XtPending() && (!wait || canit || mane.min_x < MAXDIM ||
! alt.min_x < MAXDIM || mag_moved))
if (alt_canit) longjmp(canit_env, 1);
else return;
#ifndef X10
XtNextEvent(&event);
+ if (resized) get_geom();
if (event.xany.window == alt.win &&
event.type == Expose) {
handle_exp((Widget) NULL, &alt, &event.xexpose);
***************
*** 667,685 ****
switch (event.type) {
case ExposeWindow:
if (event.window == mane.win) {
! window_h = ((XExposeEvent *)(&event))->height;
! window_w = ((XExposeEvent *)(&event))->width;
! home();
! ch = '\f';
! break;
! }
! /* otherwise control passes through */
case ExposeRegion:
/* check in case we already destroyed the window */
if (event.window == mane.win || alt.win != NULL) {
struct WindowRec *wr =
(event.window == mane.win ? &mane : &alt);
if (wr == &alt)
if (alt_stat < 0) { /* destroy upon exposure */
alt_stat = 0;
--- 806,824 ----
switch (event.type) {
case ExposeWindow:
if (event.window == mane.win) {
! register Dimension old_clip_w = clip_w;
+ window_w = ((XExposeEvent *) &event)->width;
+ window_h = ((XExposeEvent *) &event)->height;
+ if (old_clip_w == 0) home(False);
+ }
+ /* control falls through */
case ExposeRegion:
/* check in case we already destroyed the window */
if (event.window == mane.win || alt.win != NULL) {
struct WindowRec *wr =
(event.window == mane.win ? &mane : &alt);
+
if (wr == &alt)
if (alt_stat < 0) { /* destroy upon exposure */
alt_stat = 0;
***************
*** 688,713 ****
}
else
alt_stat = 0;
! #define ev ((XExposeEvent *)(&event))
! if (wr->min_x > ev->x) wr->min_x = ev->x;
! if (wr->max_x < ev->x + ev->width)
! wr->max_x = ev->x + ev->width;
! if (wr->min_y > ev->y) wr->min_y = ev->y;
! if (wr->max_y < ev->y + ev->height)
! wr->max_y = ev->y + ev->height;
! #undef ev
}
break;
case ButtonPressed: {
! int n = 0;
! switch (((XButtonPressedEvent *) (&event))->detail &
ValueMask) {
- case LeftButton: n=0; break;
case MiddleButton: n=1; break;
case RightButton: n=2; break;
}
! handle_button((XButtonPressedEvent *) (&event), mg_size[n]);
}
break;
case ButtonReleased:
--- 827,864 ----
}
else
alt_stat = 0;
! if (((XExposeEvent *) &event)->detail & ExposeCopy)
! ClearArea(event.window,
! ((XExposeEvent *) &event)->x,
! ((XExposeEvent *) &event)->y,
! ((XExposeEvent *) &event)->width,
! ((XExposeEvent *) &event)->height);
! expose(wr, ((XExposeEvent *) &event)->x,
! ((XExposeEvent *) &event)->y,
! ((XExposeEvent *) &event)->width,
! ((XExposeEvent *) &event)->height);
}
+ case ExposeCopy: /* throw away junk event */
break;
+ case MouseMoved:
+ case LeftDownMotion:
+ case MiddleDownMotion:
+ case RightDownMotion:
+ new_mag_x = ((XMouseMovedEvent *) &event)->x;
+ new_mag_y = ((XMouseMovedEvent *) &event)->y;
+ mag_moved = (new_mag_x != mag_x || new_mag_y != mag_y);
+ break;
+
case ButtonPressed: {
! register int n = 0;
! switch (((XButtonPressedEvent *) &event)->detail &
ValueMask) {
case MiddleButton: n=1; break;
case RightButton: n=2; break;
}
! alt.width = alt.height = mg_size[n];
! handle_button((XButtonPressedEvent *) &event);
}
break;
case ButtonReleased:
***************
*** 718,723 ****
--- 869,877 ----
if (nbytes > 1) goto bad;
if (nbytes != 0) ch = *string;
break;
+ /*MouseMoved */
+ default:
+ Fprintf(stderr, "???: %x\n", event.type);
}
#endif X10
if (ch == '\0') continue;
***************
*** 771,791 ****
/* redisplay current page */
break;
case '^':
! home();
! break;
! #ifndef X10
! case 'u':
! if (!scroll(False, -0.67)) goto bad;
continue;
! case 'd':
! if (!scroll(False, 0.67)) goto bad;
! continue;
case 'l':
! if (!scroll(True, -0.67)) goto bad;
continue;
case 'r':
! if (!scroll(True, 0.67)) goto bad;
continue;
case 'c':
center(event.xkey.x, event.xkey.y);
continue;
--- 925,953 ----
/* redisplay current page */
break;
case '^':
! home(True);
continue;
! #ifndef X10
case 'l':
! if (!x_bar) goto bad;
! XtCallCallbacks(x_bar, XtNscrollProc,
! -2 * (int) clip_w / 3);
continue;
case 'r':
! if (!x_bar) goto bad;
! XtCallCallbacks(x_bar, XtNscrollProc,
! 2 * (int) clip_w / 3);
continue;
+ case 'u':
+ if (!y_bar) goto bad;
+ XtCallCallbacks(y_bar, XtNscrollProc,
+ -2 * (int) clip_h / 3);
+ continue;
+ case 'd':
+ if (!y_bar) goto bad;
+ XtCallCallbacks(y_bar, XtNscrollProc,
+ 2 * (int) clip_h / 3);
+ continue;
case 'c':
center(event.xkey.x, event.xkey.y);
continue;
***************
*** 802,837 ****
ImageByteOrder(DISP));
continue;
#else X10
- case 'u':
- if (mane.base_y == 0) goto bad;
- mane.base_y -= window_h;
- if (mane.base_y < 0)
- mane.base_y = 0;
- break;
- case 'd':
- if (mane.base_y >= page_h - window_h) goto bad;
- mane.base_y += window_h;
- if (mane.base_y > page_h - window_h)
- mane.base_y = page_h - window_h;
- break;
case 'l':
if (mane.base_x == 0) goto bad;
! mane.base_x -= window_w;
! if (mane.base_x < 0)
! mane.base_x = 0;
! break;
case 'r':
! if (mane.base_x >= page_w - window_w) goto bad;
! mane.base_x += window_w;
! if (mane.base_x > page_w - window_w)
! mane.base_x = page_w - window_w;
! break;
case 'c':
! #define ev ((XKeyPressedEvent *) (&event))
! mane.base_x += ev->x - window_w/2;
! mane.base_y += ev->y - window_h/2;
XWarpMouse(mane.win, window_w/2, window_h/2, 3);
! break;
case 'M':
home_x = (ev->x + mane.base_x) * mane.shrinkfactor;
home_y = (ev->y + mane.base_y) * mane.shrinkfactor;
--- 964,999 ----
ImageByteOrder(DISP));
continue;
#else X10
case 'l':
if (mane.base_x == 0) goto bad;
! number0 = mane.base_x - 2 * clip_w / 3;
! if (number0 < 0) number0 = 0;
! scrollwindow(&mane, number0, mane.base_y);
! continue;
case 'r':
! number0 = mane.base_x + 2 * clip_w / 3;
! if (number0 > page_w - clip_w) number0 = page_w - clip_w;
! if (number0 == mane.base_x) goto bad;
! scrollwindow(&mane, number0, mane.base_y);
! continue;
! case 'u':
! if (mane.base_y == 0) goto bad;
! number0 = mane.base_y - 2 * clip_h / 3;
! if (number0 < 0) number0 = 0;
! scrollwindow(&mane, mane.base_x, number0);
! continue;
! case 'd':
! number0 = mane.base_y + 2 * clip_h / 3;
! if (number0 > page_h - clip_h) number0 = page_h - clip_h;
! if (number0 == mane.base_y) goto bad;
! scrollwindow(&mane, mane.base_x, number0);
! continue;
case 'c':
! #define ev ((XKeyPressedEvent *) &event)
! scrollwindow(&mane, mane.base_x + ev->x - window_w/2,
! mane.base_y + ev->y - window_h/2);
XWarpMouse(mane.win, window_w/2, window_h/2, 3);
! continue;
case 'M':
home_x = (ev->x + mane.base_x) * mane.shrinkfactor;
home_y = (ev->y + mane.base_y) * mane.shrinkfactor;
***************
*** 842,848 ****
if (!arg0) {
long fac1, fac2;
shrink_factor = 1;
- get_wh(vport_widget);
fac1 = ROUNDUP(PAPER_WIDTH, window_w);
fac2 = ROUNDUP(PAPER_HEIGHT, window_h);
if (fac1 < fac2)
--- 1004,1009 ----
***************
*** 853,859 ****
if (number0 <= 0) goto bad;
if (number0 == mane.shrinkfactor) continue;
shrink_factor = mane.shrinkfactor = number0;
- unmap();
init_page();
if (number0 != 1 && number0 != bak_shrink) {
bak_shrink = number0;
--- 1014,1019 ----
***************
*** 860,870 ****
reset_fonts();
}
#ifndef X10
set_draw_args();
XtSetValues(draw_widget, draw_args, 2);
! #endif X10
! home();
break;
case 'S':
if (!arg0) goto bad;
if (number0 < 0) goto bad;
--- 1020,1036 ----
reset_fonts();
}
#ifndef X10
+ XUnmapWindow(DISP, mane.win);
set_draw_args();
XtSetValues(draw_widget, draw_args, 2);
! get_geom();
! home(False);
! XMapWindow(DISP, mane.win);
! continue;
! #else X10
! home(False);
break;
+ #endif X10
case 'S':
if (!arg0) goto bad;
if (number0 < 0) goto bad;
***************
*** 872,878 ****
density = number0;
reset_fonts();
if (mane.shrinkfactor == 1) continue;
- unmap();
break;
case 'R':
/* reread DVI file */
--- 1038,1043 ----
***************
*** 885,891 ****
if (current_page != next_page) {
current_page = next_page;
spec_warn = True;
! home();
}
canit = True;
Flush();
--- 1050,1056 ----
if (current_page != next_page) {
current_page = next_page;
spec_warn = True;
! home(False);
}
canit = True;
Flush();
***************
*** 916,922 ****
max_y - min_y, min_x, min_y, curr.base_x, curr.base_y);
SetCursor(redraw_cursor);
if (errtext = (char *) setjmp(dvi_env)) {
! ClearPage();
#ifndef X10
get_xy();
XDrawString(DISP, mane.win, foreGC,
--- 1081,1087 ----
max_y - min_y, min_x, min_y, curr.base_x, curr.base_y);
SetCursor(redraw_cursor);
if (errtext = (char *) setjmp(dvi_env)) {
! ClearPage(mane);
#ifndef X10
get_xy();
XDrawString(DISP, mane.win, foreGC,
***************
*** 941,953 ****
redraw_page()
{
if (debug & DBG_EVENT) fputs("Redraw page: ", stdout);
- get_wh(clip_widget);
get_xy();
! ClearPage();
mane.min_x = -window_x;
! mane.max_x = -window_x + window_w;
mane.min_y = -window_y;
! mane.max_y = -window_y + window_h;
redraw(&mane);
}
--- 1106,1117 ----
redraw_page()
{
if (debug & DBG_EVENT) fputs("Redraw page: ", stdout);
get_xy();
! ClearPage(mane);
mane.min_x = -window_x;
! mane.max_x = -window_x + clip_w;
mane.min_y = -window_y;
! mane.max_y = -window_y + clip_h;
redraw(&mane);
}
***************
*** 975,981 ****
can_exposures(windowrec)
struct WindowRec *windowrec;
{
! windowrec->min_x = windowrec->min_y = MAXINT;
windowrec->max_x = windowrec->max_y = 0;
}
--- 1139,1145 ----
can_exposures(windowrec)
struct WindowRec *windowrec;
{
! windowrec->min_x = windowrec->min_y = MAXDIM;
windowrec->max_x = windowrec->max_y = 0;
}
***************
*** 1005,1013 ****
{
if (debug & DBG_BATCH) {
#ifndef X10
! while (mane.min_x == MAXINT) read_events(True);
#else X10
! while (mane.min_x == MAXINT)
if (setjmp(canit_env)) break;
else read_events(True);
#endif X10
--- 1169,1177 ----
{
if (debug & DBG_BATCH) {
#ifndef X10
! while (mane.min_x == MAXDIM) read_events(True);
#else X10
! while (mane.min_x == MAXDIM)
if (setjmp(canit_env)) break;
else read_events(True);
#endif X10
***************
*** 1025,1042 ****
canit = False;
can_exposures(&mane);
can_exposures(&alt);
! #ifndef X10
! if (unmapped) {
! /* this creates a redraw event */
! XMapWindow(DISP, mane.win);
! unmapped = False;
! }
! else
! #endif
! redraw_page();
}
! else if (alt.min_x < MAXINT) redraw(&alt);
! else if (mane.min_x < MAXINT) redraw(&mane);
Flush();
}
}
--- 1189,1208 ----
canit = False;
can_exposures(&mane);
can_exposures(&alt);
! redraw_page();
}
! else if (mag_moved) {
! if (alt.win == NULL) mag_moved = False;
! else if (abs(new_mag_x - mag_x) >
! 2 * abs(new_mag_y - mag_y))
! movemag(new_mag_x, mag_y);
! else if (abs(new_mag_y - mag_y) >
! 2 * abs(new_mag_x - mag_x))
! movemag(mag_x, new_mag_y);
! else movemag(new_mag_x, new_mag_y);
! }
! else if (alt.min_x < MAXDIM) redraw(&alt);
! else if (mane.min_x < MAXDIM) redraw(&mane);
Flush();
}
}
***************
*** 1249,1269 ****
top_level, vport_args, XtNumber(vport_args));
clip_widget = XtNameToWidget(vport_widget, "clip");
set_draw_args();
! draw_widget = XtCreateManagedWidget("drawing", simpleWidgetClass,
vport_widget, draw_args, XtNumber(draw_args));
! XtAddEventHandler(vport_widget, KeyPressMask, 0, handle_key,
(caddr_t) NULL);
! XtAddEventHandler(draw_widget, ExposureMask, GraphicsExpose, handle_exp,
(caddr_t) &mane);
! XtAddEventHandler(draw_widget, ButtonPressMask, 0, handle_button,
(caddr_t) NULL);
! XtAddEventHandler(draw_widget, ButtonReleaseMask, 0, handle_release,
(caddr_t) NULL);
XtRealizeWidget(top_level);
curr.win = mane.win = XtWindow(draw_widget);
- /* unmapped = True; (it was initialized this way) */
- home(); /* no need to unmap at this stage */
- unmapped = False;
if (reverse) {
if (!fore_color) fore_args.value = WhitePixelOfScreen(SCRN);
--- 1415,1436 ----
top_level, vport_args, XtNumber(vport_args));
clip_widget = XtNameToWidget(vport_widget, "clip");
set_draw_args();
! draw_widget = XtCreateManagedWidget("drawing", widgetClass,
vport_widget, draw_args, XtNumber(draw_args));
! XtAddEventHandler(vport_widget, KeyPressMask, False, handle_key,
(caddr_t) NULL);
! XtAddEventHandler(vport_widget, StructureNotifyMask, False,
! handle_resize, (caddr_t) NULL);
! XtAddEventHandler(draw_widget, ExposureMask, False, handle_exp,
(caddr_t) &mane);
! XtAddEventHandler(draw_widget, ButtonPressMask, False, handle_button,
(caddr_t) NULL);
! XtAddEventHandler(draw_widget, ButtonMotionMask, False, handle_motion,
(caddr_t) NULL);
+ XtAddEventHandler(draw_widget, ButtonReleaseMask, False, handle_release,
+ (caddr_t) NULL);
XtRealizeWidget(top_level);
curr.win = mane.win = XtWindow(draw_widget);
if (reverse) {
if (!fore_color) fore_args.value = WhitePixelOfScreen(SCRN);
***************
*** 1311,1317 ****
cr_Pixel = high_color ? hl_Pixel : fore_args.value;
{
XColor bg_Color, cr_Color;
!
bg_Color.pixel = back_args.value;
XQueryColor(DISP, DefaultColormapOfScreen(SCRN), &bg_Color);
cr_Color.pixel = cr_Pixel;
--- 1478,1484 ----
cr_Pixel = high_color ? hl_Pixel : fore_args.value;
{
XColor bg_Color, cr_Color;
!
bg_Color.pixel = back_args.value;
XQueryColor(DISP, DefaultColormapOfScreen(SCRN), &bg_Color);
cr_Color.pixel = cr_Pixel;
***************
*** 1550,1560 ****
Sprintf(def, "=%dx%d+0+0", frame.width, frame.height);
mane.win = XCreate("DVI Previewer", prog, geometry, def,
&frame, 50, 50);
- window_w = frame.width;
- window_h = frame.height;
XSelectInput(mane.win,
KeyPressed|ButtonPressed|ButtonReleased|
! ExposeWindow|ExposeRegion);
XMapWindow(mane.win);
XDefineCursor(mane.win,
XCreateCursor(xdvi_width, xdvi_height, xdvi_bits, xdvi_mask_bits,
--- 1717,1726 ----
Sprintf(def, "=%dx%d+0+0", frame.width, frame.height);
mane.win = XCreate("DVI Previewer", prog, geometry, def,
&frame, 50, 50);
XSelectInput(mane.win,
KeyPressed|ButtonPressed|ButtonReleased|
! ExposeWindow|ExposeRegion|ExposeCopy|
! LeftDownMotion|MiddleDownMotion|RightDownMotion);
XMapWindow(mane.win);
XDefineCursor(mane.win,
XCreateCursor(xdvi_width, xdvi_height, xdvi_bits, xdvi_mask_bits,
diff -cr old/xdvi.h new/xdvi.h
*** old/xdvi.h Thu Jul 13 12:52:45 1989
--- new/xdvi.h Sat Jul 8 15:05:11 1989
***************
*** 34,40 ****
#define True 1
#define False 0
! #define MAXINT 32767
#define pixel_conv(x) ((int) (((x) / shrink_factor) >> 16))
#define pixel_round(x) ((int) (((x) / shrink_factor + (1<<15)) >> 16))
--- 34,40 ----
#define True 1
#define False 0
! #define MAXDIM 32767
#define pixel_conv(x) ((int) (((x) / shrink_factor) >> 16))
#define pixel_round(x) ((int) (((x) / shrink_factor + (1<<15)) >> 16))
***************
*** 123,132 ****
char *bits; /* pointer to the bits */
};
- #ifndef MAXCHARS
- #define MAXCHARS 128 /* make 256 for 8 bit characters */
- #endif MAXCHARS
-
/*
* Per-character information.
* There is one of these for each character in a font.
--- 123,128 ----
***************
*** 173,183 ****
short size; /* dots per 5 inches */
FILE *file; /* open PXL file or NULL */
char *filename; /* name of PXL file */
read_char_proc read_char; /* function to read bitmap */
! struct glyph glyph[MAXCHARS];
};
extern struct font *current_font;
/*
* Command line flags.
--- 169,181 ----
short size; /* dots per 5 inches */
FILE *file; /* open PXL file or NULL */
char *filename; /* name of PXL file */
+ ubyte maxchar; /* largest character code */
read_char_proc read_char; /* function to read bitmap */
! struct glyph glyph[256];
};
extern struct font *current_font;
+ extern ubyte maxchar;
/*
* Command line flags.
***************
*** 205,210 ****
--- 203,209 ----
long win; /* type Window is not defined yet */
int shrinkfactor;
int base_x, base_y;
+ int width, height;
int min_x, max_x, min_y, max_y; /* for pending expose events */
} mane, alt, curr;
diff -cr old/xdvi.man.sed new/xdvi.man.sed
*** old/xdvi.man.sed Thu Jul 13 12:52:49 1989
--- new/xdvi.man.sed Mon Jul 10 13:51:21 1989
***************
*** 44,50 ****
.TP
.BI \-s " shrink"
(.shrinkFactor)
! Defines the initial shrink factor. The default value is 4.
.TP
.BI \-S " density"
(.densityPercent)
--- 44,50 ----
.TP
.BI \-s " shrink"
(.shrinkFactor)
! Defines the initial shrink factor. The default value is 3.
.TP
.BI \-S " density"
(.densityPercent)
diff -cr old/xdvi10.man.s new/xdvi10.man.s
*** old/xdvi10.man.s Thu Jul 13 12:52:51 1989
--- new/xdvi10.man.s Mon Jul 10 13:47:37 1989
***************
*** 44,50 ****
.TP
.BI \-s " shrink"
(shrinkFactor)
! Defines the initial shrink factor. The default value is 4.
.TP
.BI \-S " density"
(densityPercent)
--- 44,50 ----
.TP
.BI \-s " shrink"
(shrinkFactor)
! Defines the initial shrink factor. The default value is 3.
.TP
.BI \-S " density"
(densityPercent)
More information about the Comp.sources.x
mailing list