|
|
1.1 ! root 1: /********************************************************************* ! 2: * COPYRIGHT NOTICE * ! 3: ********************************************************************** ! 4: * This software is copyright (C) 1982 by Pavel Curtis * ! 5: * * ! 6: * Permission is granted to reproduce and distribute * ! 7: * this file by any means so long as no fee is charged * ! 8: * above a nominal handling fee and so long as this * ! 9: * notice is always included in the copies. * ! 10: * * ! 11: * Other rights are reserved except as explicitly granted * ! 12: * by written permission of the author. * ! 13: * Pavel Curtis * ! 14: * Computer Science Dept. * ! 15: * 405 Upson Hall * ! 16: * Cornell University * ! 17: * Ithaca, NY 14853 * ! 18: * * ! 19: * Ph- (607) 256-4934 * ! 20: * * ! 21: * Pavel.Cornell@Udel-Relay (ARPAnet) * ! 22: * decvax!cornell!pavel (UUCPnet) * ! 23: *********************************************************************/ ! 24: ! 25: /* ! 26: * raw.c ! 27: * ! 28: * Routines: ! 29: * raw() ! 30: * echo() ! 31: * nl() ! 32: * cbreak() ! 33: * crmode() ! 34: * noraw() ! 35: * noecho() ! 36: * nonl() ! 37: * nocbreak() ! 38: * nocrmode() ! 39: * ! 40: * cbreak() == crmode() ! 41: * nocbreak() == crmode() ! 42: * ! 43: * $Log: lib_raw.c,v $ ! 44: * Revision 1.8 93/04/12 14:13:59 bin ! 45: * Udo: third color update ! 46: * ! 47: * Revision 2.2 92/11/29 15:37:59 munk ! 48: * Conditional usage of termio ! 49: * ! 50: * Revision 1.2 92/04/13 14:38:19 bin ! 51: * update by vlad ! 52: * ! 53: * Revision 2.1 82/10/25 14:48:42 pavel ! 54: * Added Copyright Notice ! 55: * ! 56: * Revision 2.0 82/10/24 15:17:40 pavel ! 57: * Beta-one Test Release ! 58: * ! 59: * Revision 1.3 82/08/23 22:30:32 pavel ! 60: * The REAL Alpha-one Release Version ! 61: * ! 62: * Revision 1.2 82/08/19 19:11:25 pavel ! 63: * Alpha Test Release One ! 64: * ! 65: * Revision 1.1 82/08/12 18:43:18 pavel ! 66: * Initial revision ! 67: * ! 68: * ! 69: */ ! 70: ! 71: #ifdef RCSHDR ! 72: static char RCSid[] = ! 73: "$Header: /src386/usr/lib/ncurses/RCS/lib_raw.c,v 1.8 93/04/12 14:13:59 bin Exp Locker: bin $"; ! 74: #endif ! 75: ! 76: #include "curses.h" ! 77: #include "curses.priv.h" ! 78: #include "term.h" ! 79: ! 80: ! 81: raw() ! 82: { ! 83: #ifdef TRACE ! 84: if (_tracing) ! 85: _tracef("raw() called"); ! 86: #endif ! 87: ! 88: #ifdef USE_TERMIO ! 89: cur_term->Ntermio.c_lflag &= ~(ECHOK|ECHONL|ISIG|ICANON); ! 90: cur_term->Ntermio.c_oflag &= ~(OPOST); ! 91: cur_term->Ntermio.c_cc[VMIN] = DEF_VMIN; ! 92: cur_term->Ntermio.c_cc[VTIME] = DEF_VTIME; ! 93: ioctl(cur_term->Filedes, TCSETA, &cur_term->Ntermio); ! 94: #else ! 95: cur_term->Nttyb.sg_flags |= RAW; ! 96: stty(cur_term->Filedes, &cur_term->Nttyb); ! 97: #endif ! 98: ! 99: SP->_raw = TRUE; ! 100: SP->_nlmapping = TRUE; ! 101: } ! 102: ! 103: ! 104: cbreak() ! 105: { ! 106: #ifdef TRACE ! 107: if (_tracing) ! 108: _tracef("cbreak() called"); ! 109: #endif ! 110: ! 111: #ifdef USE_TERMIO ! 112: cur_term->Ntermio.c_lflag &= ~ICANON; ! 113: ioctl(cur_term->Filedes, TCSETA, &cur_term->Ntermio); ! 114: #else ! 115: cur_term->Nttyb.sg_flags |= CBREAK; ! 116: stty(cur_term->Filedes, &cur_term->Nttyb); ! 117: #endif ! 118: ! 119: SP->_cbreak = TRUE; ! 120: } ! 121: ! 122: ! 123: crmode() ! 124: { ! 125: #ifdef TRACE ! 126: if (_tracing) ! 127: _tracef("crmode() called"); ! 128: #endif ! 129: ! 130: cbreak(); ! 131: } ! 132: ! 133: ! 134: echo() ! 135: { ! 136: #ifdef TRACE ! 137: if (_tracing) ! 138: _tracef("echo() called"); ! 139: #endif ! 140: ! 141: #ifdef USE_TERMIO ! 142: cur_term->Ntermio.c_lflag |= ECHO; ! 143: ioctl(cur_term->Filedes, TCSETA, &cur_term->Ntermio); ! 144: #else ! 145: cur_term->Nttyb.sg_flags |= ECHO; ! 146: stty(cur_term->Filedes, &cur_term->Nttyb); ! 147: #endif ! 148: ! 149: SP->_echo = TRUE; ! 150: } ! 151: ! 152: ! 153: nl() ! 154: { ! 155: #ifdef TRACE ! 156: if (_tracing) ! 157: _tracef("nl() called"); ! 158: #endif ! 159: ! 160: #ifdef USE_TERMIO ! 161: cur_term->Ntermio.c_iflag |= ICRNL; ! 162: cur_term->Ntermio.c_oflag |= ONLCR; ! 163: ioctl(cur_term->Filedes, TCSETA, &cur_term->Ntermio); ! 164: #else ! 165: cur_term->Nttyb.sg_flags |= CRMOD; ! 166: stty(cur_term->Filedes, &cur_term->Nttyb); ! 167: #endif ! 168: ! 169: SP->_nl = TRUE; ! 170: SP->_nlmapping = ! SP->_raw; ! 171: } ! 172: ! 173: ! 174: noraw() ! 175: { ! 176: #ifdef TRACE ! 177: if (_tracing) ! 178: _tracef("noraw() called"); ! 179: #endif ! 180: ! 181: #ifdef USE_TERMIO ! 182: cur_term->Ntermio.c_lflag |= (ECHOK|ECHONL|ISIG|ICANON); ! 183: cur_term->Ntermio.c_oflag |= OPOST; ! 184: cur_term->Ntermio.c_cc[VEOF] = DEF_VEOF; ! 185: cur_term->Ntermio.c_cc[VEOL] = DEF_VEOL; ! 186: ioctl(cur_term->Filedes, TCSETA, &cur_term->Ntermio); ! 187: #else ! 188: cur_term->Nttyb.sg_flags &= ~RAW; ! 189: stty(cur_term->Filedes, &cur_term->Nttyb); ! 190: #endif ! 191: ! 192: SP->_raw = FALSE; ! 193: SP->_nlmapping = SP->_nl; ! 194: } ! 195: ! 196: nocbreak() ! 197: { ! 198: #ifdef TRACE ! 199: if (_tracing) ! 200: _tracef("nocbreak() called"); ! 201: #endif ! 202: ! 203: #ifdef USE_TERMIO ! 204: cur_term->Ntermio.c_lflag |= ICANON; ! 205: ioctl(cur_term->Filedes, TCSETA, &cur_term->Ntermio); ! 206: #else ! 207: cur_term->Nttyb.sg_flags &= ~CBREAK; ! 208: stty(cur_term->Filedes, &cur_term->Nttyb); ! 209: #endif ! 210: ! 211: SP->_cbreak = FALSE; ! 212: } ! 213: ! 214: ! 215: nocrmode() ! 216: { ! 217: #ifdef TRACE ! 218: if (_tracing) ! 219: _tracef("nocrmode() called"); ! 220: #endif ! 221: ! 222: nocbreak(); ! 223: } ! 224: ! 225: ! 226: noecho() ! 227: { ! 228: #ifdef TRACE ! 229: if (_tracing) ! 230: _tracef("noecho() called"); ! 231: #endif ! 232: ! 233: #ifdef USE_TERMIO ! 234: cur_term->Ntermio.c_lflag &= ~ECHO; ! 235: ioctl(cur_term->Filedes, TCSETA, &cur_term->Ntermio); ! 236: #else ! 237: cur_term->Nttyb.sg_flags &= ~ECHO; ! 238: stty(cur_term->Filedes, &cur_term->Nttyb); ! 239: #endif ! 240: ! 241: SP->_echo = FALSE; ! 242: } ! 243: ! 244: ! 245: nonl() ! 246: { ! 247: #ifdef TRACE ! 248: if (_tracing) ! 249: _tracef("nonl() called"); ! 250: #endif ! 251: ! 252: #ifdef USE_TERMIO ! 253: cur_term->Ntermio.c_iflag &= ~ICRNL; ! 254: cur_term->Ntermio.c_oflag &= ~ONLCR; ! 255: ioctl(cur_term->Filedes, TCSETA, &cur_term->Ntermio); ! 256: #else ! 257: cur_term->Nttyb.sg_flags &= ~CRMOD; ! 258: stty(cur_term->Filedes, &cur_term->Nttyb); ! 259: #endif ! 260: ! 261: SP->_nl = FALSE; ! 262: SP->_nlmapping = FALSE; ! 263: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.