home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / gle / gle / unixscr.c < prev    next >
C/C++ Source or Header  |  1992-11-29  |  4KB  |  274 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.     if (y<1) y=1;
  59.     move(y+vx_top-2,x);
  60. }
  61. insline()
  62. {
  63.     int x;
  64.     int y;
  65.     getyx(stdscr,y,x);
  66.     move(y,x);
  67.     insertln();
  68.     move(y,x);
  69.     move(22,1);
  70.     clrtobot();
  71.     move(y,x);
  72.  
  73. }
  74. putch(int char_val)
  75. {
  76.     int x;
  77.     int y;
  78.     getyx(stdscr,y,x);
  79.     mvaddch(y,x,char_val);
  80. }
  81. int scr_refresh()
  82. {
  83.     if (!noscreenio) refresh();
  84. }
  85. int scr_getch()
  86. {
  87.     if (noscreenio) return getc(stdin);
  88.     else return getch();
  89. }
  90. void trap();
  91. void trap()
  92. {
  93.     echo();
  94.     nl();
  95.     nocbreak();
  96.     endwin();
  97.     exit(1);
  98. }
  99. scr_init()
  100. {
  101.     static int doneinit;
  102. #ifdef ultrix
  103.     signal(SIGINT,trap);
  104. #endif
  105. #ifdef aix
  106.     signal(SIGINT,trap);
  107. #endif
  108.     if (doneinit) {printf("init called twice \n"); exit();}
  109.     doneinit = true;
  110.     initscr();
  111.     scrollok(stdscr,true);
  112. #ifdef unix
  113.     noecho();
  114.     nonl();
  115.     cbreak();
  116.     clear();
  117. /* The AIX R6000 goes looney if you set keypad to be true, */
  118. #ifndef NOKEYPAD
  119.     keypad(stdscr,TRUE);
  120. #endif
  121. #endif
  122. }
  123. scr_end()
  124. {
  125.     if (noscreenio) return;
  126.     echo();
  127.     nl();
  128.     nocbreak();
  129.     endwin();
  130. }
  131. textbackground(int color_num)
  132. {}
  133. textcolor(int colornum)
  134. {}
  135. gettextinfo(struct text_info *r)
  136. {
  137.     int x;
  138.     int y;
  139.     if (noscreenio) return;
  140.     getyx(stdscr,y,x);
  141.     r->curx = x;
  142.     r->cury = y;
  143.     r->wintop = vx_top;
  144. }
  145. screen_save()
  146. {}
  147. screen_restore()
  148. {
  149.     if (noscreenio) return;
  150.     scr_norm();
  151.     clrscr();
  152.     gotoxy(1,1);
  153.     cputs("\n");
  154. }
  155. int wyerr;
  156. w_message(char *s)
  157. {
  158.     wyerr++;
  159.     if (noscreenio) return;
  160.     scr_savexy();
  161.     gotoxy(1,wyerr);
  162.     clreol();
  163.     cputs(s);
  164.     scr_restorexy();
  165. }
  166. window(int left,int top, int right, int bottom)
  167. {
  168.     if (left==1 && top==1 && bottom==25) {
  169.     if (noscreenio) return;
  170. #ifndef unix
  171.         printf("\x1b[%d;%dr",1,24);
  172. #endif
  173.     }
  174.     vx_top = top;
  175.     vx_bot = bottom;
  176.     wyerr = 0;
  177. }
  178. clrscr()
  179. {
  180.     if (noscreenio) return;
  181.     if (vx_top==1 && vx_bot==25) {
  182.         clearok(stdscr,TRUE);
  183.         clear();
  184.         refresh();
  185.         clearok(stdscr,FALSE);
  186.         return;
  187.     }
  188.     clear();
  189. }
  190. scr_dots(int i)
  191. {
  192. }
  193. scr_left(int i)
  194. {
  195.     int y,x;
  196.     if (i<=0) return;
  197.     getyx(stdscr,y,x);
  198.     move(y,x-i);
  199. }
  200. scr_right(int i)
  201. {
  202.     int y,x;
  203.     if (i<=0) return;
  204.     getyx(stdscr,y,x);
  205.     move(y,x+i);
  206. }
  207. int vx_topsave,vx_botsave;
  208. int savex,savey;
  209. scr_savexy()
  210. {
  211.     if (noscreenio) return;
  212.     getyx(stdscr,savey,savex);
  213.     vx_topsave = vx_top;
  214.     vx_botsave = vx_bot;
  215.  
  216. }
  217. scr_restorexy()
  218. {
  219.     if (noscreenio) return;
  220.     move(savey,savex);
  221.     vx_top = vx_topsave;
  222.     vx_bot = vx_botsave;
  223. }
  224.  
  225. scr_norm()  /* yellow on blue */
  226. {
  227. #ifndef NOATTRIB
  228.     attrset(A_NORMAL);
  229. #endif
  230. }
  231. scr_inv()   /* black on white */
  232. {
  233. #ifndef NOATTRIB
  234.     attrset(A_BOLD);
  235. #endif
  236. }
  237. scr_grey()  /* black on grey */
  238. {
  239. #ifndef NOATTRIB
  240.     attrset(A_REVERSE);
  241. #endif
  242. }
  243. scr_isblackwhite()
  244. {
  245.     return true;
  246. }
  247. scr_menubg()
  248. {
  249.     scr_norm();
  250. }
  251. scr_menuval()
  252. {
  253.     scr_inv();
  254. }
  255. scr_menuhi()
  256. {
  257.  
  258.     scr_grey();
  259. }
  260.  
  261. #ifndef unix
  262. #include <descrip.h>
  263. vax_edt(char *s)     /* call the vax EDT editor */
  264. {
  265.     $DESCRIPTOR(sdesc,"");
  266.     sdesc.dsc$a_pointer = s;
  267.     sdesc.dsc$w_length = strlen(s);
  268.     edt$edit(&sdesc,&sdesc);
  269. }
  270. #else
  271. vax_edt(char *s)
  272. {}
  273. #endif
  274.