1 /* Error window
2 
3  * Copyright (C) 1998 J.A. Bezemer
4  *
5  * Licensed under the terms of the GNU General Public License.
6  * ABSOLUTELY NO WARRANTY.
7  * See the file `COPYING' in this directory.
8  */
9 
10 #include "errorwindow.h"
11 #ifndef SWIG
12 #include "buttons.h"
13 #include "boxes.h"
14 #include "textwindow.h"
15 
16 #include <string.h>
17 #ifndef OLD_CURSES
18 #include <ncurses.h>
19 #else
20 #include <curses.h>
21 #endif
22 #else
23 #include <stdio.h>
24 #endif
25 
26 void
error_window_display(char * text,char * buttontext)27 error_window_display (char *text, char *buttontext)
28 {
29 #ifndef SWIG
30   button_t ok_button;
31 
32   ok_button.text = buttontext;
33   ok_button.y = ERROR_WINDOW_Y + ERROR_WINDOW_H - 1;
34   ok_button.x = ERROR_WINDOW_X + ERROR_WINDOW_W
35     - 1 - strlen (ok_button.text);
36   ok_button.selected = TRUE;
37 
38   mybox (ERROR_WINDOW_Y - 1, ERROR_WINDOW_X - 1,
39 	 ERROR_WINDOW_H + 2, ERROR_WINDOW_W + 2);
40   display_textwin ("", ERROR_WINDOW_Y, ERROR_WINDOW_X,
41 		   ERROR_WINDOW_H, ERROR_WINDOW_W);
42   display_textwin (text, ERROR_WINDOW_Y, ERROR_WINDOW_X + 1,
43 		   ERROR_WINDOW_H, ERROR_WINDOW_W - 2);
44   button_display (&ok_button);
45   move (0, 79);
46   refresh ();
47 #else
48   printf("%s\n",text);
49 #endif
50 }
51 
52 
53 void
error_window(char * text)54 error_window (char *text)
55 {
56 #ifndef SWIG
57   int i;
58 #endif
59 
60   error_window_display (text, " OK ");
61 
62 #ifndef SWIG
63   do
64     i = getch ();
65   while (i != 13 && i != KEY_ENTER && i != 27);
66 
67   clear ();
68   refresh ();
69 #endif
70 }
71