home *** CD-ROM | disk | FTP | other *** search
- /* > $.CLIB.C.text
- *
- * HASWIN Graphics Library
- * =========================
- *
- * Copyright (C) H.A.Shaw 1990.
- * Howard A. Shaw.
- * The Unit for Space Sciences,
- * Room 165,
- * Physics Building,
- * University of Kent at Canterbury.
- * Canterbury.
- * Kent. CT2 7NJ
- * You may use and distribute this code freely, however please leave
- * it alone. If you find bugs (and there will be many) please contact
- * me and the master source can be modified. If you keep me informed
- * of who you give copies of this to then I can get release upgrades
- * to them.
- *
- * These routines provide a text area in a window. The text is stored
- * as a 2-D array of characters. The routines draw parts of the area,
- * insert and delete characters and lines, scroll the text and provide
- * a VDU stream like interface. It is possible to find things out
- * about the text and set its foreground and background colours. The
- * text in a window does not need to cover the whole of the window, but
- * is always aligned with the top left corner of the window work area.
- */
- #include "includes.h"
- #include <stdarg.h>
-
- /*
- * draw the given text area on the screen. The area is "txt", the
- * graphics X and Y coords of the area to be drawn is (gx0,gy0) to
- * (gx1,gy1). adjx, adjy are the coordinate adjustments to get from
- * screen coords to window coords. This routine is called in a similar
- * way to the graphics_plot() routine to do the graphics bits of a
- * window. If the top bit of the character is set flip the foreground
- * and background colours.
- */
- void text_plot(text *txt, int adjx, int adjy, int gx0, int gx1, int gy0,
- int gy1) {
-
- register char *ptr, ch;
- register int x, sx, ex, y;
- int sy, ey, charx, chary, intext, xpos, ypos, flip;
-
- if ((!txt) || (!txt->text))
- return;
- charx = haswin_readvduvariable(VDUVAR_CharXsize);
- chary = haswin_readvduvariable(VDUVAR_CharYsize);
- sy = (adjy-gy1)/chary;
- ey = ((adjy-gy0)/chary)+1;
- if (ey >= txt->ysize)
- ey = txt->ysize-1;
- sx = (gx0-adjx)/charx;
- ex = (gx1-adjx)/charx+1;
- if (ex >= txt->xsize)
- ex = txt->xsize-1;
- ypos = adjy-sy*chary;
- graphics_gcol(0, txt->bcol);
- graphics_rectanglefill(adjx+sx*charx, ypos,
- (ex-sx+1)*charx, (sy-ey-1)*chary);
- graphics_gcol(0, txt->fcol);
- for (y=sy; y<=ey; y++) {
- ptr = &txt->text[sx+y*txt->xsize];
- intext = HASWIN_FALSE;
- xpos = adjx+sx*charx;
- for (x=sx; x<=ex; x++) {
- if (*ptr & 0x80) {
- ch = *ptr & 0x7f;
- flip = HASWIN_TRUE;
- graphics_gcol(0, txt->fcol);
- graphics_rectanglefill(xpos+charx-1, ypos-chary, 1-charx, chary);
- graphics_gcol(0, txt->bcol);
- } else {
- if (flip) {
- graphics_gcol(0, txt->fcol);
- flip = HASWIN_FALSE;
- }
- ch = *ptr;
- }
- if ((ch > ' ') && (ch < 127)) {
- if (!intext) {
- intext=HASWIN_TRUE;
- graphics_move(xpos, ypos);
- }
- putchar(ch);
- } else {
- intext = HASWIN_FALSE;
- }
- xpos += charx;
- ptr++;
- }
- ypos -= chary;
- }
- return;
- }
-
- /*
- * create a new, or alter an existing text area.
- * If on entry either x or y are zero their value is taken from an
- * existing text area in the window.
- */
- text *haswin_textmakearea(text *txt, int x, int y, char f, char b) {
-
- text *tmptxt;
- register char *ptr1, *ptr2;
- register int j, xe, ye;
-
- if (txt) {
- if (x == 0)
- x = txt->xsize;
- if (y == 0)
- y = txt->ysize;
- }
- if ((x <= 0) || (y <= 0))
- return(HASWIN_FALSE);
- tmptxt = haswin_malloc(sizeof(text), "haswin_maketextarea", "text block");
- if (!tmptxt)
- return(HASWIN_FALSE);
- tmptxt->text = haswin_malloc(x*y, "haswin_maketextarea", "text characters");
- if (!tmptxt->text) {
- haswin_free(tmptxt);
- return(HASWIN_FALSE);
- }
- memset(tmptxt->text, ' ', x*y);
- tmptxt->xsize = x;
- tmptxt->ysize = y;
- tmptxt->xposn = tmptxt->yposn = 0;
- tmptxt->fcol = f;
- tmptxt->bcol = b;
- if (txt) {
- if (txt->text) {
- xe = (txt->xsize > x) ? x : txt->xsize;
- ye = (txt->ysize > y) ? y : txt->ysize;
- ptr1 = tmptxt->text;
- ptr2 = txt->text;
- for (j=0; j<ye; j++) {
- memcpy(ptr1, ptr2, xe);
- ptr1 += tmptxt->xsize;
- ptr2 += txt->xsize;
- }
- haswin_free(txt->text);
- }
- free(txt);
- }
- return(tmptxt);
- }
-
- /*
- * create a new, or alter an existing text area.
- * If on entry either x or y are zero their value is taken from an
- * existing text area in the window.
- */
- int haswin_maketextoverlay(window *win, int x, int y, char f, char b) {
-
- int ox, oy;
-
- if ((int)win <= 0)
- return(0);
- if (win->text) {
- ox = win->text->xposn;
- oy = win->text->xposn;
- } else
- ox = -1;
- if ((win->text=haswin_textmakearea(win->text, x, y, f, b)) == 0)
- return(0);
- if (!win->caret)
- win->caret = haswin_makecaret(win, 0, 0, 0,
- haswin_readvduvariable(VDUVAR_CharYsize),
- 11, CARET_REALCOL, 0);
- if (ox != -1)
- haswin_textmove(win, ox, oy);
- return(HASWIN_TRUE);
- }
-
- /*
- * mark the given text area to be redrawn.
- */
- int haswin_textredraw(window *win, int x0, int x1, int y0, int y1) {
-
- int charx, chary;
-
- if (((int)win <= 0) || (!win->text))
- return(HASWIN_FALSE);
- if (!(haswin_getwindowflags(win) & WINDOW_OPEN))
- return(HASWIN_TRUE);
- charx = haswin_readvduvariable(VDUVAR_CharXsize);
- chary = haswin_readvduvariable(VDUVAR_CharYsize);
- if (!haswin_converttxtxytowin(win, &x0, &y0))
- return(HASWIN_FALSE);
- if (!haswin_converttxtxytowin(win, &x1, &y1))
- return(HASWIN_FALSE);
- haswin_redrawwindow(win, x0-charx, x1+charx, y0-chary, y1+chary);
- return(HASWIN_TRUE);
- }
-
- /*
- * we provide a similar interface to that provided by the Archimedes
- * VDU drivers. The following commands are understood.
- * character action
- * ^@ 0 NULL
- * ^G 7 ring the bell
- * ^H 8 move left (stops at left edge)
- * ^I 9 move right (wraps to next line, stops at bottom)
- * ^J 10 move down (bottom wraps to top)
- * ^K 11 move up (top wraps to bottom)
- * ^L 12 clear text (move cursor to top left)
- * ^M 13 move to begining of next line (can scroll)
- * ^N 14 insert character
- * ^O 15 insert line
- * ^P 16 delete character
- * ^Q 17 delete line
- * ^R 18 scroll left
- * ^S 19 scroll right
- * ^T 20 scroll down
- * ^U 21 scroll up
- * ^* 30 move cursor to top left.
- * ^_ 31 move cursor to X, Y.
- * <sp>-~ 32-126 character added to text (wraps to next line, scrolls)
- * ^? 127 delete character and move left (stops at left edge)
- *
- * new characters added to the text overwrite those that are already
- * there.
- */
-
- int haswin_textvdu(window *win, char ch) {
-
- register char *ptr, *end;
- caret car;
-
- if (((int)win <= 0) || (!win->text) || (!win->text->text))
- return(HASWIN_FALSE);
- if ((ch < 0) || (ch > 127))
- return(HASWIN_FALSE);
- switch (ch) {
- case 0:
- break;
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- return(HASWIN_FALSE);
- case 7:
- haswin_bell();
- break;
- case 8:
- win->text->xposn--;
- break;
- case 9:
- win->text->xposn++;
- break;
- case 10:
- win->text->yposn--;
- break;
- case 11:
- win->text->yposn++;
- break;
- case 12:
- end = &win->text->text[win->text->xsize*win->text->ysize];
- for (ptr=win->text->text; ptr<end; ptr++)
- *ptr = (*ptr & 0x80) | ' ';
- win->text->xposn = win->text->yposn = 0;
- haswin_textredraw(win,0,win->text->xsize,win->text->ysize,0);
- break;
- case 13:
- win->text->yposn++;
- win->text->xposn = 0;
- break;
- case 14:
- haswin_textinsertchar(win,win->text->xposn,win->text->yposn);
- break;
- case 15:
- haswin_textinsertline(win, win->text->yposn);
- break;
- case 16:
- haswin_textdeletechar(win,win->text->xposn,win->text->yposn);
- break;
- case 17:
- haswin_textdeleteline(win, win->text->yposn);
- break;
- case 18:
- haswin_textscrollleft(win);
- break;
- case 19:
- haswin_textscrollright(win);
- break;
- case 20:
- haswin_textscrolldown(win);
- break;
- case 21:
- haswin_textscrollup(win);
- break;
- case 22:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
- case 28:
- case 29:
- return(HASWIN_FALSE);
- case 30:
- haswin_textmove(win, 0, 0);
- break;
- case 31:
- break;
- case 127:
- win->text->xposn--;
- if (win->text->xposn < 0)
- win->text->xposn = 0;
- haswin_textdeletechar(win,win->text->xposn,win->text->yposn);
- break;
- default:
- ptr = &win->text->text[win->text->xposn+win->text->xsize*win->text->yposn];
- *ptr = (*ptr & 0x80) | (ch & 0x7F);
- haswin_textredraw(win, win->text->xposn, win->text->xposn,
- win->text->yposn, win->text->yposn);
- win->text->xposn++;
- break;
- }
- if (win->text->xposn >= win->text->xsize) {
- win->text->xposn = 0;
- win->text->yposn++;
- } else if (win->text->xposn < 0) {
- win->text->xposn = 0;
- }
- if (win->text->yposn >= win->text->ysize) {
- win->text->yposn = win->text->ysize-1;
- haswin_textscrolldown(win);
- } else if (win->text->yposn < 0) {
- win->text->yposn = 0;
- }
- if (win->caret) {
- win->caret->x = haswin_converttxtxtowin(win, win->text->xposn);
- win->caret->y = haswin_converttxtytowin(win, win->text->yposn) - haswin_readvduvariable(VDUVAR_CharYsize);
- haswin_getcaretinfo(&car);
- if ((car.win == win) && (car.ic == 0) &&
- (haswin_getwindowflags(win) & WINDOW_OPEN))
- haswin_setcaret(win->caret);
- }
- return(HASWIN_TRUE);
- }
-
- int haswin_textsetmark(window *win, int x0, int x1, int y0, int y1) {
-
- register char *ptr;
- register int x, y;
-
- if (((int)win <= 0) || (!win->text))
- return(HASWIN_FALSE);
- if ((x0<0) || (x1<0) || (y0<0) || (y1<0) || (x1<x0) || (y1<y0))
- return(HASWIN_FALSE);
- if ((x1 >= win->text->xsize) || (y1 >= win->text->ysize))
- return(HASWIN_FALSE);
- for (y=y0; y<=y1; y++) {
- ptr = &win->text->text[x0+y*win->text->xsize];
- for (x=x0; x<=x1; x++) {
- *ptr++ |= 0x80;
- }
- }
- return((x1-x0)*(y1-y0));
- }
-
- int haswin_textclearmark(window *win, int x0, int x1, int y0, int y1) {
-
- register char *ptr;
- register int x, y;
-
- if (((int)win <= 0) || (!win->text))
- return(HASWIN_FALSE);
- if ((x0<0) || (x1<0) || (y0<0) || (y1<0) || (x1<x0) || (y1<y0))
- return(HASWIN_FALSE);
- if ((x1 >= win->text->xsize) || (y1 >= win->text->ysize))
- return(HASWIN_FALSE);
- for (y=y0; y<=y1; y++) {
- ptr = &win->text->text[x0+y*win->text->xsize];
- for (x=x0; x<=x1; x++) {
- *ptr++ &= 0x7F;
- }
- }
- return((x1-x0)*(y1-y0));
- }
-
- int haswin_textdeletechar(window *win, int x, int y) {
-
- register int i;
- register char *ptr, *ptr1;
-
- if (((int)win <= 0) || (!win->text) || (!win->text->text))
- return(HASWIN_FALSE);
- if (x < 0)
- x = 0;
- else if (x >= win->text->xsize)
- x = win->text->xsize - 1;
- if (y < 0)
- y = 0;
- else if (y >= win->text->ysize)
- y = win->text->ysize - 1;
- ptr = &(win->text->text[x+y*win->text->xsize]);
- ptr1 = ptr++;
- for (i=x+1; i<win->text->xsize; i++)
- *ptr1++ = *ptr++;
- *ptr1 = ' ';
- haswin_textredraw(win, x+1, win->text->xsize, y, y);
- return(HASWIN_TRUE);
- }
-
- int haswin_textdeleteline(window *win, int y) {
-
- register int i;
- register char *ptr, *ptr1;
-
- if (((int)win <= 0) || (!win->text) || (!win->text->text))
- return(HASWIN_FALSE);
- if (y < 0)
- y = 0;
- else if (y >= win->text->ysize)
- y = win->text->ysize - 1;
- ptr = &(win->text->text[y*win->text->xsize]);
- ptr1 = ptr+win->text->xsize;
- for (i=y+1; i<win->text->ysize; i++) {
- memcpy(ptr, ptr1, win->text->xsize);
- ptr += win->text->xsize;
- ptr1 += win->text->xsize;
- }
- memset(ptr, ' ', win->text->xsize);
- haswin_textredraw(win, 0, win->text->xsize, win->text->ysize, y);
- return(HASWIN_TRUE);
- }
-
- int haswin_textinsertchar(window *win, int x, int y) {
-
- register int i;
- register char *ptr, *ptr1;
-
- if (((int)win <= 0) || (!win->text) || (!win->text->text))
- return(HASWIN_FALSE);
- if (x < 0)
- x = 0;
- else if (x >= win->text->xsize)
- x = win->text->xsize - 1;
- if (y < 0)
- y = 0;
- else if (y >= win->text->ysize)
- y = win->text->ysize - 1;
- ptr = &(win->text->text[(y+1)*win->text->xsize-1]);
- ptr1 = ptr--;
- for (i=x+1; i<win->text->xsize; i++)
- *ptr1-- = *ptr--;
- ptr[1] = ' ';
- haswin_textredraw(win, x+1, win->text->xsize, y, y);
- return(HASWIN_TRUE);
- }
-
- int haswin_textinsertline(window *win, int y) {
-
- register int i;
- register char *ptr, *ptr1;
-
- if (((int)win <= 0) || (!win->text) || (!win->text->text))
- return(HASWIN_FALSE);
- if (y < 0)
- y = 0;
- else if (y >= win->text->ysize)
- y = win->text->ysize - 1;
- ptr = &(win->text->text[(win->text->ysize-1)*win->text->xsize]);
- ptr1 = ptr-win->text->xsize;
- for (i=y+1; i<win->text->ysize; i++) {
- memcpy(ptr, ptr1, win->text->xsize);
- ptr -= win->text->xsize;
- ptr1 -= win->text->xsize;
- }
- memset(ptr, ' ', win->text->xsize);
- haswin_textredraw(win, 0, win->text->xsize, win->text->ysize, y);
- return(HASWIN_TRUE);
- }
-
- int haswin_textscrolldown(window *win) {
-
- return(haswin_textdeleteline(win, 0));
- }
-
- int haswin_textscrollup(window *win) {
-
- return(haswin_textinsertline(win, 0));
- }
-
- int haswin_textscrollright(window *win) {
-
- register int i, y;
- register char *ptr, *ptr1;
-
- if (((int)win <= 0) || (!win->text) || (!win->text->text))
- return(HASWIN_FALSE);
- for (y=0; y<win->text->ysize; y++) {
- ptr = &(win->text->text[(y+1)*win->text->xsize-1]);
- ptr1 = ptr--;
- for (i=1; i<win->text->xsize; i++)
- *ptr1-- = *ptr--;
- ptr[1] = ' ';
- }
- haswin_textredraw(win, 0, win->text->xsize, win->text->ysize, 0);
- return(HASWIN_TRUE);
- }
-
- int haswin_textscrollleft(window *win) {
-
- register int i, y;
- register char *ptr, *ptr1;
-
- if (((int)win <= 0) || (!win->text) || (!win->text->text))
- return(HASWIN_FALSE);
- for (y=0; y<win->text->ysize; y++) {
- ptr = &(win->text->text[y*win->text->xsize]);
- ptr1 = ptr++;
- for (i=1; i<win->text->xsize; i++)
- *ptr1++ = *ptr++;
- *ptr1 = ' ';
- }
- haswin_textredraw(win, 0, win->text->xsize, win->text->ysize, 0);
- return(HASWIN_TRUE);
- }
- int haswin_textgetchar(window *win, int x, int y) {
-
- if (((int)win <= 0) || (!win->text) || (!win->text->text))
- return(-1);
- if (x < 0)
- x = 0;
- else if (x >= win->text->xsize)
- x = win->text->xsize - 1;
- if (y < 0)
- y = 0;
- else if (y >= win->text->ysize)
- y = win->text->ysize - 1;
- return(win->text->text[x*y]);
- }
-
- int haswin_textgetblock(window *win, int x0, int y0, int x1, int y1) {
-
- if (((int)win <= 0) || (!win->text) || (!win->text->text))
- return(HASWIN_FALSE);
- if (x0 < 0)
- x0 = 0;
- else if (x0 >= win->text->xsize)
- x0 = win->text->xsize - 1;
- if (y0 < 0)
- y0 = 0;
- else if (y0 >= win->text->ysize)
- y0 = win->text->ysize - 1;
- if (x1 < 0)
- x1 = 0;
- else if (x1 >= win->text->xsize)
- x1 = win->text->xsize - 1;
- if (y1 < 0)
- y1 = 0;
- else if (y1 >= win->text->ysize)
- y1 = win->text->ysize - 1;
- if ((x0 >= x1) || (y0 >= y1))
- return(HASWIN_FALSE);
- return(HASWIN_TRUE);
- }
-
- int haswin_textmove(window *win, int x, int y) {
-
- int ret = HASWIN_TRUE;
-
- if (((int)win <= 0) || (!win->text) || (!win->text->text))
- return(HASWIN_FALSE);
- if (x < 0) {
- x = 0;
- ret = HASWIN_FALSE;
- } else if (x >= win->text->xsize) {
- x = win->text->xsize - 1;
- ret = HASWIN_FALSE;
- }
- if (y < 0) {
- y = 0;
- ret = HASWIN_FALSE;
- } else if (y >= win->text->ysize) {
- y = win->text->ysize - 1;
- ret = HASWIN_FALSE;
- }
- if (win->caret) {
- win->caret->x = haswin_converttxtxtowin(win, x);
- win->caret->y = haswin_converttxtytowin(win, y) - haswin_readvduvariable(VDUVAR_CharYsize);
- if (haswin_getwindowflags(win) & WINDOW_OPEN)
- haswin_setcaret(win->caret);
- }
- win->text->xposn = x;
- win->text->yposn = y;
- return(ret);
- }
-
- /*
- * do printf() in the text window given.
- */
- int haswin_textprintf(window *win, char *fmt, ...) {
-
- char *ptr;
- va_list ap;
- int len;
- /* We have to try and guess the length of the final string to
- allocate memory for it. Remember that we will only need the
- memory for a short time. Guess at 10K. */
- char str[10240];
-
- if (((int)win <= 0) || (!win->text) || (!win->text->text))
- return(HASWIN_FALSE);
- va_start(ap, fmt);
- len = vsprintf(str, fmt, ap);
- ptr = str;
- while (*ptr) {
- haswin_textvdu(win, *ptr++);
- }
- va_end(ap);
- return(len);
- }
-
- int haswin_textgetxposn(window *win) {
-
- if (((int)win <= 0) || (!win->text))
- return(-1);
- return(win->text->xposn);
- }
-
- int haswin_textgetyposn(window *win) {
-
- if (((int)win <= 0) || (!win->text))
- return(-1);
- return(win->text->yposn);
- }
-
- int haswin_textgetxsize(window *win) {
-
- if (((int)win <= 0) || (!win->text))
- return(-1);
- return(win->text->xsize);
- }
-
- int haswin_textgetysize(window *win) {
-
- if (((int)win <= 0) || (!win->text))
- return(-1);
- return(win->text->ysize);
- }
-
- /*
- * convert window and text x to a x offset in the window (left of char).
- */
- int haswin_converttxtxtowin(window *wptr, int x) {
-
- if ((int)wptr <= 0)
- return(x);
- if (!wptr->text)
- return(HASWIN_UNKNOWN);
- if (x < 0)
- x = 0;
- else if (x >= wptr->text->xsize)
- x = wptr->text->xsize-1;
- x *= haswin_readvduvariable(VDUVAR_CharXsize);
- return(x-wptr->orgx);
- }
-
- /*
- * convert window and text y to a y offset in the window (bottom of
- * char).
- */
- int haswin_converttxtytowin(window *wptr, int y) {
-
- if ((int)wptr <= 0)
- return(y);
- if (!wptr->text)
- return(HASWIN_UNKNOWN);
- if (y < 0)
- y = 0;
- else if (y >= wptr->text->ysize)
- y = wptr->text->ysize-1;
- y *= haswin_readvduvariable(VDUVAR_CharYsize);
- return(wptr->orgy-y);
- }
-
- /*
- * convert window and x,y text position to a x,y offset in the window.
- */
- int haswin_converttxtxytowin(window *wptr, int *x, int *y) {
-
- if (((int)wptr <= 0) || (!wptr->text))
- return(HASWIN_FALSE);
- if (*x < 0)
- *x = 0;
- else if (*x >= wptr->text->xsize)
- *x = wptr->text->xsize-1;
- if (*y < 0)
- *y = 0;
- else if (*y >= wptr->text->ysize)
- *y = wptr->text->ysize-1;
- *x *= haswin_readvduvariable(VDUVAR_CharXsize);
- *y *= haswin_readvduvariable(VDUVAR_CharYsize);
-
- *x = *x - wptr->orgx;
- *y = wptr->orgy - *y;
- return(HASWIN_TRUE);
- }
-
- /*
- * convert window and x offset to text x position in window.
- */
- int haswin_convertwinxtotxt(window *wptr, int x) {
-
- if ((int)wptr <= 0)
- return(x);
- if (!wptr->text)
- return(HASWIN_UNKNOWN);
- x = (x+wptr->orgx)/haswin_readvduvariable(VDUVAR_CharXsize);
- if (x <= 0)
- return(0);
- if (x > wptr->text->xsize-1)
- return(wptr->text->xsize-1);
- return(x);
- }
-
- /*
- * convert window and y offset to text y position in window.
- */
- int haswin_convertwinytotxt(window *wptr, int y) {
-
- if ((int)wptr <= 0)
- return(y);
- if (!wptr->text)
- return(HASWIN_UNKNOWN);
- y = (wptr->orgy-y)/haswin_readvduvariable(VDUVAR_CharYsize);
- if (y <= 0)
- return(0);
- if (y > wptr->text->ysize-1)
- return(wptr->text->ysize-1);
- return(y);
- }
-
- /*
- * convert window and x,y offset pair to text position in window.
- */
- int haswin_convertwinxytotxt(window *wptr, int *x, int *y) {
-
- if (((int)wptr <= 0) || (!wptr->text))
- return(HASWIN_FALSE);
- *x = (*x+wptr->orgx)/haswin_readvduvariable(VDUVAR_CharXsize);
- if (*x < 0)
- *x = 0;
- else if (*x > wptr->text->xsize-1)
- *x = wptr->text->xsize-1;
- *y = (wptr->orgy- *y)/haswin_readvduvariable(VDUVAR_CharYsize);
- if (*y < 0)
- *y = 0;
- else if (*y > wptr->text->ysize-1)
- *y = wptr->text->ysize-1;
- return(HASWIN_TRUE);
- }
-
- /*
- * convert a text x position and a window to the real position on the
- * screen.
- */
- int haswin_converttxtxtoscr(window *wptr, int x) {
-
- return(haswin_convertwinxtoscr(wptr, haswin_converttxtxtowin(wptr, x)));
- }
-
- /*
- * convert a text y position and a window to the real position on the
- * screen.
- */
- int haswin_converttxtytoscr(window *wptr, int y) {
-
- return(haswin_convertwinytoscr(wptr, haswin_converttxtytowin(wptr, y)));
- }
-
- /*
- * convert a text x,y pair and a window to the real position on the
- * screen.
- */
- int haswin_converttxtxytoscr(window *wptr, int *x, int *y) {
-
- if (haswin_converttxtxytowin(wptr, x, y))
- return(haswin_convertwinxytoscr(wptr, x, y));
- else
- return(HASWIN_FALSE);
- }
-
- /*
- * convert a real x position on the screen to a text position in the
- * window
- */
- int haswin_convertscrxtotxt(window *wptr, int x) {
-
- return(haswin_convertwinxtotxt(wptr, haswin_convertscrxtowin(wptr, x)));
- }
-
- /*
- * convert a real y position on the screen to a text position in the
- * window
- */
- int haswin_convertscrytotxt(window *wptr, int y) {
-
- return(haswin_convertwinytotxt(wptr, haswin_convertscrytowin(wptr, y)));
- }
-
- /*
- * convert a real x,y pair on the screen to a text position in the
- * window
- */
- int haswin_convertscrxytotxt(window *wptr, int *x, int *y) {
-
- if (haswin_convertscrxytowin(wptr, x, y))
- return(haswin_convertwinxytotxt(wptr, x, y));
- else
- return(HASWIN_FALSE);
- }
-
-