1 /* 2 * term.h: header file for term.c 3 * 4 * Written By Michael Sandrof 5 * 6 * Copyright (c) 1990 Michael Sandrof. 7 * Copyright (c) 1991, 1992 Troy Rollo. 8 * Copyright (c) 1992-2003 Matthew R. Green. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 3. The name of the author may not be used to endorse or promote products 20 * derived from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR 23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 25 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * $Id: ircterm.h,v 1.9 2006-10-31 12:31:27 f Exp $ 35 */ 36 37 #ifndef __ircterm_h_ 38 # define __ircterm_h_ 39 40 #ifdef INCLUDE_CURSES_H 41 # include <curses.h> 42 #endif /* INCLUDE_CURSES_H */ 43 44 /**************************** PATCHED by Flier ******************************/ 45 #ifdef SZNCURSES 46 #include <ncurses.h> 47 #endif /* SZNCURSES */ 48 /****************************************************************************/ 49 50 /* this is really busted on solaris -mrg */ 51 #if 0 52 #ifdef INCLUDE_TERM_H 53 # include <term.h> 54 # ifdef lines 55 # undef lines 56 # endif /* lines */ 57 # ifdef columns 58 # undef columns 59 # endif /* columns */ 60 #endif /* INCLUDE_TERM_H */ 61 #endif /* 0 */ 62 63 #ifdef MUNIX 64 # include <sys/ttold.h> 65 #endif /* MUNIX */ 66 67 extern int term_reset_flag; 68 /**************************** PATCHED by Flier ******************************/ 69 #ifndef SZNCURSES 70 /****************************************************************************/ 71 extern char *CM, 72 *DO, 73 *CE, 74 *CL, 75 *CR, 76 *NL, 77 *SO, 78 *SE, 79 *US, 80 *UE, 81 *MD, 82 *ME, 83 *BL, 84 *TI, 85 *TE; 86 /**************************** PATCHED by Flier ******************************/ 87 #endif /* SZNCURSES */ 88 /****************************************************************************/ 89 extern int SG; 90 /**************************** PATCHED by Flier ******************************/ 91 #ifdef WANTANSI 92 extern char *SETAF, 93 *SETAB; 94 extern int NUMCOLORS; 95 #endif /* WANTANSI */ 96 /****************************************************************************/ 97 98 #ifdef NCURSES_VERSION 99 # define TPUTSRETVAL int 100 # define TPUTSARGVAL int 101 #else 102 # ifdef HPUX 103 # define TPUTSRETVAL int 104 # define TPUTSARGVAL char 105 # else /* HPUX */ 106 # ifdef __sgi 107 # include <sys/param.h> 108 # define TPUTSRETVAL int 109 # define TPUTSARGVAL char 110 # endif 111 # if (defined(__sgi) && defined(SEEKLIMIT32)) || defined(__osf__) || defined(__SVR4) 112 /* 113 * XXX 114 * 115 * if this causes your compile to fail, then just delete it. and 116 * please tell me (use the `ircbug' command). thanks. 117 */ 118 char *tgetstr(char *, char **); 119 # endif 120 # ifndef __sgi 121 # if defined(__linux__) || defined(_AIX) || defined(__GNU__) || defined(__FreeBSD__) || (defined(__NetBSD_Version__) && __NetBSD_Version__ >= 104100000) 122 # define TPUTSRETVAL int 123 # define TPUTSARGVAL int 124 # else 125 # define TPUTSVOIDRET 1 126 # define TPUTSRETVAL void 127 # define TPUTSARGVAL int 128 # endif /* __linux || _AIX */ 129 # endif /* __sgi */ 130 # endif /* HPUX */ 131 #endif /* NCURSES_VERSION */ 132 133 TPUTSRETVAL putchar_x _((TPUTSARGVAL)); 134 135 #define tputs_x(s) (tputs(s, 0, putchar_x)) 136 137 /**************************** PATCHED by Flier ******************************/ 138 #ifdef SZNCURSES 139 #define term_underline_on() (attron(A_UNDERLINE)) 140 #define term_underline_off() (attroff(A_UNDERLINE)) 141 #define term_standout_on() (attron(A_REVERSE)) 142 #define term_standout_off() (attroff(A_REVERSE)) 143 #define term_clear_screen() (clear()) 144 #define term_move_cursor(c, r) (move(r,c)) 145 #define term_cr() {} 146 #define term_newline() (addch('\n')) 147 #define term_beep() (beep()) 148 #define term_bold_on() (attron(A_BOLD)) 149 #define term_bold_off() (attroff(A_BOLD)) 150 151 #else /* SZNCURSES */ 152 /****************************************************************************/ 153 154 #define term_underline_on() (tputs_x(US)) 155 #define term_underline_off() (tputs_x(UE)) 156 #define term_standout_on() (tputs_x(SO)) 157 #define term_standout_off() (tputs_x(SE)) 158 #define term_clear_screen() (tputs_x(CL)) 159 #define term_move_cursor(c, r) (tputs_x(tgoto(CM, (c), (r)))) 160 #define term_cr() (tputs_x(CR)) 161 #define term_newline() (tputs_x(NL)) 162 #define term_beep() (tputs_x(BL),fflush(current_screen ? \ 163 current_screen->fpout : stdout)) 164 #define term_bold_on() (tputs_x(MD)) 165 #define term_bold_off() (tputs_x(ME)) 166 /**************************** PATCHED by Flier ******************************/ 167 #endif /* SZNCURSES */ 168 /****************************************************************************/ 169 170 RETSIGTYPE term_cont _((void)); 171 void term_set_fp _((FILE *)); 172 void term_init _((void)); 173 /**************************** PATCHED by Flier ******************************/ 174 void term_close _((void)); 175 /****************************************************************************/ 176 int term_resize _((void)); 177 void term_pause _((u_int, char *)); 178 int tputs_s _((char *, size_t)); 179 void term_flush _((void)); 180 void term_space_erase _((int)); 181 void term_reset _((void)); 182 void copy_window_size _((int *, int *)); 183 int term_eight_bit _((void)); 184 void set_term_eight_bit _((int)); 185 /**************************** PATCHED by Flier ******************************/ 186 #ifdef SZNCURSES 187 int term_read _((char *buf, size_t count)); 188 #endif /* SZNCURSES */ 189 /****************************************************************************/ 190 191 extern int (*term_scroll) _((int, int, int)); 192 extern int (*term_insert) _((u_int)); 193 #if 0 194 extern int (*term_insert_kanji) _((u_int, u_int)); 195 #endif 196 extern int (*term_delete) _((void)); 197 extern int (*term_cursor_right) _((void)); 198 extern int (*term_cursor_left) _((void)); 199 extern int (*term_clear_to_eol) _((void)); 200 201 #if defined(ISC22) || defined(MUNIX) 202 /* Structure for terminal special characters */ 203 struct tchars 204 { 205 char t_intrc; /* Interrupt */ 206 char t_quitc; /* Quit */ 207 char t_startc; /* Start output */ 208 char t_stopc; /* Stop output */ 209 char t_eofc; /* End-of-file (EOF) */ 210 char t_brkc; /* Input delimiter (like nl) */ 211 } 212 213 struct ltchars 214 { 215 char t_suspc; /* stop process signal */ 216 char t_dsuspc; /* delayed stop process signal */ 217 char t_rprntc; /* reprint line */ 218 char t_flushc; /* flush output (toggles) */ 219 char t_werasc; /* word erase */ 220 char t_lnextc; /* literal next character */ 221 }; 222 #endif /* ISC22 || MUNIX */ 223 224 #if defined(_HPUX_SOURCE) 225 226 #ifndef _TTY_CHARS_ST_ 227 #define _TTY_CHARS_ST_ 228 229 /* Structure for terminal special characters */ 230 struct tchars 231 { 232 char t_intrc; /* Interrupt */ 233 char t_quitc; /* Quit */ 234 char t_startc; /* Start output */ 235 char t_stopc; /* Stop output */ 236 char t_eofc; /* End-of-file (EOF) */ 237 char t_brkc; /* Input delimiter (like nl) */ 238 }; 239 240 #endif /* _TTY_CHARS_ST_ */ 241 242 #ifndef TIOCSETC 243 # define TIOCSETC _IOW('t', 17, struct tchars) /* set special chars */ 244 #endif /* TIOCSETC */ 245 246 #ifndef TIOCGETC 247 # define TIOCGETC _IOR('t', 18, struct tchars) /* get special chars */ 248 #endif /* TIOCGETC */ 249 250 #ifndef CBREAK 251 # define CBREAK 0x02 /* Half-cooked mode */ 252 #endif /* CBREAK */ 253 254 #ifndef SIGWINCH 255 # define SIGWINCH SIGWINDOW 256 #endif /* SIGWINCH */ 257 258 #endif /* _HPUX_SOURCE */ 259 260 /* well, it works */ 261 #ifdef mips 262 # ifndef HAVE_FPUTC 263 # define fputc(c,f) do { char x = (c); write(fileno(f),&x,1); } while (0) 264 # endif /* HAVE_FPUTC */ 265 # ifndef HAVE_FWRITE 266 # define fwrite(buffer,len,cnt,f) write(fileno(f),(buffer),(len)*(cnt)) 267 # endif /* HAVE_FWRITE */ 268 #endif /* mips */ 269 270 /**************************** PATCHED by Flier ******************************/ 271 /****** Patched by Zakath ******/ 272 /* Linux/Alpha has a problem with incompat betw termio/termios */ 273 #if defined(linux) && defined(__alpha__) 274 # undef TCGETA 275 # define TCGETA TCGETS 276 # undef TCSETA 277 # define TCSETA TCSETS 278 # undef TCSETAW 279 # define TCSETAW TCSETSW 280 # undef termio 281 # define termio termios 282 #endif /* linux && __alpha__ */ 283 /****** ***************** ******/ 284 /****************************************************************************/ 285 286 #endif /* __ircterm_h_ */ 287