]> code.citadel.org Git - citadel.git/blob - citadel/textclient/screen.c
Removed curses fullscreen mode in the text client, in preparation for something even...
[citadel.git] / citadel / textclient / screen.c
1 /*
2  * Screen output handling
3  */
4
5 #include <stdlib.h>
6 #include <unistd.h>
7 #include <stdio.h>
8 #include <signal.h>
9 #include <string.h>
10 #include <stdarg.h>
11 #include <sys/types.h>
12 #include "sysdep.h"
13 #ifndef HAVE_SNPRINTF
14 #include "snprintf.h"
15 #endif
16 #include <libcitadel.h>
17 #include "citadel.h"
18 #include "citadel_ipc.h"
19 #include "citadel_decls.h"
20 #include "commands.h"
21 #include "screen.h"
22
23 char arg_screen;
24
25 extern int screenheight;
26 extern int screenwidth;
27 extern int rc_ansi_color;
28 extern void check_screen_dims(void);
29
30 void do_keepalive(void);
31
32
33 /*
34  * Initialize the screen
35  */
36 void screen_new(void)
37 {
38         send_ansi_detect();
39         look_for_ansi();
40         cls(0);
41         color(DIM_WHITE);
42 }
43
44
45 /*
46  * Kill the screen completely (used at exit).  It is safe to call this
47  * function more than once.
48  */
49 void screen_delete(void)
50 {
51         windows_delete();
52         screen_reset();
53 }
54
55 /*
56  * Beep.
57  */
58 void ctdl_beep(void) {
59         putc(7, stdout);
60 }
61         
62
63
64 /*
65  * Set screen/IO parameters, e.g. at start of program or return from external
66  * program run.
67  */
68 int screen_set(void)
69 {
70         return 0;
71 }
72
73
74 /*
75  * Reset screen/IO parameters, e.g. at exit or fork of external program.
76  */
77 int screen_reset(void)
78 {
79         return 0;
80 }
81
82
83 /*
84  * scr_printf() outputs to the terminal
85  */
86 int scr_printf(char *fmt, ...)
87 {
88         va_list ap;
89         register int retval;
90
91         va_start(ap, fmt);
92         retval = vprintf(fmt, ap);
93         va_end(ap);
94         return retval;
95 }
96
97
98 /*
99  * err_printf() outputs to error status window (or stderr if not in curses)
100  */
101 int err_printf(char *fmt, ...)
102 {
103         va_list ap;
104         register int retval;
105
106         va_start(ap, fmt);
107         retval = vfprintf(stderr, fmt, ap);
108         va_end(ap);
109         return retval;
110 }
111
112
113 /*
114  * sln_printf() outputs to error status window (or stderr if not in curses)
115  */
116 int sln_printf(char *fmt, ...)
117 {
118         va_list ap;
119         register int retval;
120         va_start(ap, fmt);
121         retval = vprintf(fmt, ap);
122         va_end(ap);
123         return retval;
124 }
125
126
127 /*
128  * sln_printf_if() outputs to status window, no output if not in curses
129  */
130 int sln_printf_if(char *fmt, ...)
131 {
132         register int retval = 1;
133         return retval;
134 }
135
136
137 int scr_getc(int delay)
138 {
139         unsigned char buf;
140         buf = '\0';
141         if (!read (0, &buf, 1))
142                 logoff(NULL, 3);
143         return buf;
144 }
145
146 /*
147  * scr_putc() outputs a single character
148  */
149 int scr_putc(int c)
150 {
151         if (putc(c, stdout) == EOF)
152                 logoff(NULL, 3);
153         return c;
154 }
155
156
157 int sln_putc(int c)
158 {
159         return putc(c, stdout);
160 }
161
162
163 int sln_putc_if(int c)
164 {
165         return 1;
166 }
167
168
169 /*
170  * scr_color() sets the window color for mainwindow
171  */
172 int scr_color(int colornum)
173 {
174         return 0;
175 }
176
177
178 void scr_flush(void)
179 {
180         fflush(stdout);
181 }
182
183
184 void err_flush(void)
185 {
186                 fflush(stderr);
187 }
188
189
190 void sln_flush(void)
191 {
192         fflush(stdout);
193 }
194
195 static volatile int caught_sigwinch = 0;
196
197 /*
198  * this is not supposed to be called from a signal handler.
199  */
200 int scr_set_windowsize(CtdlIPC* ipc)
201 {
202         return 0;
203 }
204
205 /*
206  * scr_winch() handles window size changes from SIGWINCH
207  * resizes all our windows for us
208  */
209 RETSIGTYPE scr_winch(int signum)
210 {
211         /* if we receive this signal, we must be running
212          * in a terminal that supports resizing.
213          */
214         have_xterm = 1;
215         caught_sigwinch = 1;
216         check_screen_dims();
217         signal(SIGWINCH, scr_winch);
218 }
219
220
221 /*
222  * Initialize the window(s) we will be using.
223  */
224 void windows_new(void)
225 {
226 }
227
228
229 /*
230  * Deinitialize the window(s) we were using (at exit).
231  */
232 void windows_delete(void)
233 {
234 }