home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / gle / util / manip / unixscr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-11-29  |  3.4 KB  |  269 lines

  1. #include <stdio.h>
  2. #ifdef ultrix
  3. #include <cursesX.h>
  4. #else
  5. #include <curses.h>
  6. #endif
  7. #include <signal.h>
  8. #include "vaxconio.h"
  9. #define false 0
  10. #define true (!false)
  11. #define dbg if (1==1)
  12. extern int noscreenio;
  13. delay(int i)
  14. {}
  15. int vx_top=1,vx_bot=24;
  16. textattr()
  17. {}
  18. abort_key()
  19. {
  20.     return false;
  21. }
  22. kbhit()
  23. {
  24.     return false;
  25. }
  26. scr_gets(char *x)
  27. {
  28.     getstr(x);
  29. }
  30. clreol()
  31. {
  32.     if (noscreenio) return;
  33.     clrtoeol();
  34. }
  35. cputs(char *line)
  36. {
  37.     int x;
  38.     int y;
  39.     if (noscreenio) return;
  40.     getyx(stdscr,y,x);
  41.     mvaddstr(y,x,line);
  42. }
  43. delline()
  44. {
  45.     int x;
  46.     int y;
  47.     getyx(stdscr,y,x);
  48.     move(22,1);
  49.     clrtobot();
  50.     move(y,1);
  51.     deleteln();
  52.     move(y,x);
  53. }
  54. gotoxy(int x, int y)
  55. {
  56.     if (noscreenio) return;
  57.     if (y==25) y=24;
  58.     move(y+vx_top-2,x);
  59. }
  60. insline()
  61. {
  62.     int x;
  63.     int y;
  64.     getyx(stdscr,y,x);
  65.     move(y,x);
  66.     insertln();
  67.     move(y,x);
  68.     move(22,1);
  69.     clrtobot();
  70.     move(y,x);
  71.  
  72. }
  73. putch(int char_val)
  74. {
  75.     int x;
  76.     int y;
  77.     getyx(stdscr,y,x);
  78.     mvaddch(y,x,char_val);
  79. }
  80. int scr_refresh()
  81. {
  82.     if (!noscreenio) refresh();
  83. }
  84. int scr_getch()
  85. {
  86.     if (noscreenio) return getc(stdin);
  87.     else return getch();
  88. }
  89. trap(int sig)
  90. {
  91.     echo();
  92.     nl();
  93.     nocbreak();
  94.     endwin();
  95.     exit(sig);
  96. }
  97. scr_init()
  98. {
  99.     static int doneinit;
  100. #ifdef ultrix
  101.     signal(SIGINT,trap);
  102. #endif
  103.     if (doneinit) {printf("init called twice \n"); exit();}    
  104.     doneinit = true;
  105.     initscr();
  106.     scrollok(stdscr,true);
  107. #ifdef unix
  108.     noecho();
  109.     nonl();
  110.     cbreak();
  111.     clear();
  112. /* The AIX R6000 goes looney if you set keypad to be true, */
  113. #ifndef NOKEYPAD
  114.     keypad(stdscr,TRUE);
  115. #endif
  116. #endif
  117. }
  118. scr_end()
  119. {
  120.     if (noscreenio) return;
  121.     echo();
  122.     nl();
  123.     nocbreak();
  124.     endwin();
  125. }
  126. textbackground(int color_num)
  127. {}
  128. textcolor(int colornum)
  129. {}
  130. gettextinfo(struct text_info *r)
  131. {
  132.     int x;
  133.     int y;
  134.     if (noscreenio) return;
  135.     getyx(stdscr,y,x);
  136.     r->curx = x;
  137.     r->cury = y;
  138.     r->wintop = vx_top;
  139. }
  140. screen_save()
  141. {}
  142. screen_restore()
  143. {
  144.     if (noscreenio) return;
  145.     scr_norm();
  146.     clrscr();
  147.     gotoxy(1,1);
  148.     cputs("\n");
  149. }
  150. int wyerr;
  151. w_message(char *s)
  152. {
  153.     wyerr++;
  154.     if (noscreenio) return;
  155.     scr_savexy();
  156.     gotoxy(1,wyerr);
  157.     clreol();
  158.     cputs(s);
  159.     scr_restorexy();
  160. }    
  161. window(int left,int top, int right, int bottom)
  162. {
  163.     if (left==1 && top==1 && bottom==25) {
  164.     if (noscreenio) return;
  165. #ifndef unix
  166.         printf("\x1b[%d;%dr",1,24);
  167. #endif
  168.     }     
  169.     vx_top = top;
  170.     vx_bot = bottom;
  171.     wyerr = 0;
  172. }
  173. clrscr()
  174. {
  175.     if (noscreenio) return;
  176.     if (vx_top==1 && vx_bot==25) {
  177.         clearok(stdscr,TRUE);
  178.         clear();
  179.         refresh();
  180.         clearok(stdscr,FALSE);
  181.         return;
  182.     }
  183.     clear();
  184. }
  185. scr_dots(int i)
  186. {
  187. }
  188. scr_left(int i)
  189. {
  190.     int y,x;
  191.     if (i<=0) return;
  192.     getyx(stdscr,y,x);
  193.     move(y,x-i);
  194. }
  195. scr_right(int i)
  196. {
  197.     int y,x;
  198.     if (i<=0) return;
  199.     getyx(stdscr,y,x);
  200.     move(y,x+i);
  201. }
  202. int vx_topsave,vx_botsave;
  203. int savex,savey;
  204. scr_savexy()
  205. {
  206.     if (noscreenio) return;
  207.     getyx(stdscr,savey,savex);
  208.     vx_topsave = vx_top;
  209.     vx_botsave = vx_bot;
  210.     
  211. }
  212. scr_restorexy()
  213. {
  214.     if (noscreenio) return;
  215.     move(savey,savex);
  216.     vx_top = vx_topsave;
  217.     vx_bot = vx_botsave;
  218. }
  219.  
  220. scr_norm()  /* yellow on blue */
  221. {
  222. #ifndef NOATTRIB
  223.     attrset(A_NORMAL);
  224. #endif
  225. }
  226. scr_inv()   /* black on white */
  227. {
  228. #ifndef NOATTRIB
  229.     attrset(A_BOLD);
  230. #endif
  231. }
  232. scr_grey()  /* black on grey */
  233. {
  234. #ifndef NOATTRIB
  235.     attrset(A_REVERSE);
  236. #endif
  237. }
  238. scr_isblackwhite()
  239. {
  240.     return true;
  241. }
  242. scr_menubg()
  243. {
  244.     scr_norm();
  245. }
  246. scr_menuval()
  247. {
  248.     scr_inv();
  249. }
  250. scr_menuhi()
  251. {
  252.  
  253.     scr_grey();
  254. }
  255.  
  256. #ifndef unix
  257. #include <descrip.h>
  258. vax_edt(char *s)     /* call the vax EDT editor */
  259. {
  260.     $DESCRIPTOR(sdesc,"");
  261.     sdesc.dsc$a_pointer = s;
  262.     sdesc.dsc$w_length = strlen(s);
  263.     edt$edit(&sdesc,&sdesc);
  264. }
  265. #else
  266. vax_edt(char *s)
  267. {}
  268. #endif
  269.