#include #include getregion(argc, argv, index, fx, fy, nx, ny, device) int argc; char *argv[]; int *index, *fx, *fy, *nx, *ny; int device; { struct umipscf a; ERRTYPE err; int height, width, got=0; int startindex = *index; if (err = dd_rddevice(device, DEV_HEIGHT, &height)) errprnt(dd_err(err)); if (err = dd_rddevice(device, DEV_WIDTH, &width)) errprnt(dd_err(err)); /* (fx fy) (fx fy nx ny) (O) (T) (B) (R) (L) (TL) (TR) (BL) (BR) */ getuenv(&a); *fx = a.fx; *fy = a.fy; *nx = a.nx; *ny = a.ny; if ((*fx >= width) || (*fy >= height)) errprnt("window not on device"); if (*fx + *nx > width) *nx = width - *fx; if (*fy + *ny > height) *ny = height - *fy; if (*index >= argc) return(0); got |= ordarg2(argc, argv, index, "I", fx, "I", fy); got |= ordarg2(argc, argv, index, "I", nx, "I", ny); if (!got) { if (strlen(argv[*index]) == 1) { switch (argv[*index][0]) { case 'O' : *fx = 0; *fy = 0; *nx = width; *ny = height; break; case 'T' : *fx = 0; *fy = 0; *nx = width; *ny = height/2; break; case 'B' : *fx = 0; *fy = height/2; *nx = width; *ny = height - *fy; break; case 'L' : *fx = 0; *fy = 0; *nx = width/2; *ny = height; break; case 'R' : *fx = width/2; *fy = 0; *nx = width - *fx; *ny = height; break; default : *index -= 1; } *index += 1; } else if (strlen(argv[*index]) == 2) { if ((strcmp(argv[*index], "TL") == 0) || (strcmp(argv[*index], "LT") == 0)) { *fx = 0; *fy = 0; *nx = width/2; *ny = height/2; } else if ((strcmp(argv[*index], "TR") == 0) || (strcmp(argv[*index], "RT") == 0)) { *fx = width/2; *fy = 0; *nx = width - *fx; *ny = height/2; } else if ((strcmp(argv[*index], "BL") == 0) || (strcmp(argv[*index], "LB") == 0)) { *fx = 0; *fy = height/2; *nx = width/2; *ny = height - *fy; } else if ((strcmp(argv[*index], "BR") == 0) || strcmp(argv[*index], "RB") == 0) { *fx = width/2; *fy = height/2; *nx = width - *fx; *ny = height - *fy; } else *index -= 1; *index += 1; } } if ((*fx >= width) || (*fy >= height)) errprnt("window not on device"); if (*fx + *nx > width) *nx = width - *fx; if (*fy + *ny > height) *ny = height - *fy; a.fx = *fx; a.fy = *fy; a.nx = *nx; a.ny = *ny; setuenv(&a); if (*index == startindex) return(0); else return(1); }