| 1 | #ifndef lint |
| 2 | static char *sccsid = "@(#)wwmisc.c 3.4 83/11/28"; |
| 3 | #endif |
| 4 | |
| 5 | #include "ww.h" |
| 6 | |
| 7 | /* |
| 8 | * Sufficient but not necessary test for total visibility. |
| 9 | */ |
| 10 | wwvisible(w) |
| 11 | register struct ww *w; |
| 12 | { |
| 13 | register i; |
| 14 | register nvis = 0; |
| 15 | |
| 16 | for (i = w->ww_i.t; i < w->ww_i.b; i++) |
| 17 | nvis += w->ww_nvis[i]; |
| 18 | if (w->ww_hascursor |
| 19 | && w->ww_cur.r >= w->ww_i.b && w->ww_cur.r < w->ww_i.t |
| 20 | && w->ww_cur.c >= w->ww_i.l && w->ww_cur.c < w->ww_i.r |
| 21 | && wwsmap[w->ww_cur.r][w->ww_cur.c] == w->ww_index) |
| 22 | nvis++; |
| 23 | return nvis == w->ww_i.nr * w->ww_i.nc; |
| 24 | } |
| 25 | |
| 26 | char * |
| 27 | unctrl(c) |
| 28 | register c; |
| 29 | { |
| 30 | static char buf[5]; |
| 31 | register char *p = buf; |
| 32 | |
| 33 | c = (unsigned)(unsigned char)c; |
| 34 | if (c == DEL) { |
| 35 | *p++ = '^'; |
| 36 | *p++ = '?'; |
| 37 | } else if (c < ' ') { |
| 38 | *p++ = '^'; |
| 39 | *p++ = c + '@'; |
| 40 | } else if (c > DEL) { |
| 41 | *p++ = '\\'; |
| 42 | *p++ = (c >> 6 & 3) + '0'; |
| 43 | *p++ = (c >> 3 & 7) + '0'; |
| 44 | *p++ = (c & 7) + '0'; |
| 45 | } else |
| 46 | *p++ = c; |
| 47 | *p = 0; |
| 48 | return buf; |
| 49 | } |