set.c (92922) | set.c (200419) |
---|---|
1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 19 unchanged lines hidden (view full) --- 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> 35 | 1/*- 2 * Copyright (c) 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 19 unchanged lines hidden (view full) --- 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 */ 33 34#include <sys/cdefs.h> 35 |
36__FBSDID("$FreeBSD: head/usr.bin/tset/set.c 92922 2002-03-22 01:42:45Z imp $"); | 36__FBSDID("$FreeBSD: head/usr.bin/tset/set.c 200419 2009-12-11 23:30:22Z delphij $"); |
37 38#ifndef lint 39static const char sccsid[] = "@(#)set.c 8.2 (Berkeley) 2/28/94"; 40#endif 41 42#include <stdio.h> | 37 38#ifndef lint 39static const char sccsid[] = "@(#)set.c 8.2 (Berkeley) 2/28/94"; 40#endif 41 42#include <stdio.h> |
43#include <termcap.h> |
|
43#include <termios.h> 44#include <unistd.h> 45 46#include "extern.h" 47 48#define CHK(val, dft) (val <= 0 ? dft : val) 49 50int set_tabs(void); 51 52/* 53 * Reset the terminal mode bits to a sensible state. Very useful after 54 * a child program dies in raw mode. 55 */ 56void | 44#include <termios.h> 45#include <unistd.h> 46 47#include "extern.h" 48 49#define CHK(val, dft) (val <= 0 ? dft : val) 50 51int set_tabs(void); 52 53/* 54 * Reset the terminal mode bits to a sensible state. Very useful after 55 * a child program dies in raw mode. 56 */ 57void |
57reset_mode() | 58reset_mode(void) |
58{ 59 tcgetattr(STDERR_FILENO, &mode); 60 61#if defined(VDISCARD) && defined(CDISCARD) 62 mode.c_cc[VDISCARD] = CHK(mode.c_cc[VDISCARD], CDISCARD); 63#endif 64 mode.c_cc[VEOF] = CHK(mode.c_cc[VEOF], CEOF); 65 mode.c_cc[VERASE] = CHK(mode.c_cc[VERASE], CERASE); --- 84 unchanged lines hidden (view full) --- 150 tcsetattr(STDERR_FILENO, TCSADRAIN, &mode); 151} 152 153/* 154 * Determine the erase, interrupt, and kill characters from the termcap 155 * entry and command line and update their values in 'mode'. 156 */ 157void | 59{ 60 tcgetattr(STDERR_FILENO, &mode); 61 62#if defined(VDISCARD) && defined(CDISCARD) 63 mode.c_cc[VDISCARD] = CHK(mode.c_cc[VDISCARD], CDISCARD); 64#endif 65 mode.c_cc[VEOF] = CHK(mode.c_cc[VEOF], CEOF); 66 mode.c_cc[VERASE] = CHK(mode.c_cc[VERASE], CERASE); --- 84 unchanged lines hidden (view full) --- 151 tcsetattr(STDERR_FILENO, TCSADRAIN, &mode); 152} 153 154/* 155 * Determine the erase, interrupt, and kill characters from the termcap 156 * entry and command line and update their values in 'mode'. 157 */ 158void |
158set_control_chars() | 159set_control_chars(void) |
159{ 160 char *bp, *p, bs_char, buf[1024]; 161 162 bp = buf; 163 p = tgetstr("kb", &bp); 164 if (p == NULL || p[1] != '\0') 165 p = tgetstr("bc", &bp); 166 if (p != NULL && p[1] == '\0') --- 20 unchanged lines hidden (view full) --- 187 188/* 189 * Set up various conversions in 'mode', including parity, tabs, returns, 190 * echo, and case, according to the termcap entry. If the program we're 191 * running was named with a leading upper-case character, map external 192 * uppercase to internal lowercase. 193 */ 194void | 160{ 161 char *bp, *p, bs_char, buf[1024]; 162 163 bp = buf; 164 p = tgetstr("kb", &bp); 165 if (p == NULL || p[1] != '\0') 166 p = tgetstr("bc", &bp); 167 if (p != NULL && p[1] == '\0') --- 20 unchanged lines hidden (view full) --- 188 189/* 190 * Set up various conversions in 'mode', including parity, tabs, returns, 191 * echo, and case, according to the termcap entry. If the program we're 192 * running was named with a leading upper-case character, map external 193 * uppercase to internal lowercase. 194 */ 195void |
195set_conversions(usingupper) 196 int usingupper; | 196set_conversions(int usingupper) |
197{ 198 if (tgetflag("UC") || usingupper) { 199#ifdef IUCLC 200 mode.c_iflag |= IUCLC; 201 mode.c_oflag |= OLCUC; 202#endif 203 } else if (tgetflag("LC")) { 204#ifdef IUCLC --- 28 unchanged lines hidden (view full) --- 233 mode.c_lflag &= ~ECHO; 234 if (tgetflag("pt")) /* Print tabs. */ 235 mode.c_oflag &= ~OXTABS; 236 mode.c_lflag |= (ECHOE | ECHOK); 237} 238 239/* Output startup string. */ 240void | 197{ 198 if (tgetflag("UC") || usingupper) { 199#ifdef IUCLC 200 mode.c_iflag |= IUCLC; 201 mode.c_oflag |= OLCUC; 202#endif 203 } else if (tgetflag("LC")) { 204#ifdef IUCLC --- 28 unchanged lines hidden (view full) --- 233 mode.c_lflag &= ~ECHO; 234 if (tgetflag("pt")) /* Print tabs. */ 235 mode.c_oflag &= ~OXTABS; 236 mode.c_lflag |= (ECHOE | ECHOK); 237} 238 239/* Output startup string. */ 240void |
241set_init() | 241set_init(void) |
242{ 243 char *bp, buf[1024]; 244 int settle; 245 246 bp = buf; 247 if (tgetstr("pc", &bp) != 0) /* Get/set pad character. */ 248 PC = buf[0]; 249 --- 27 unchanged lines hidden (view full) --- 277 278/* 279 * Set the hardware tabs on the terminal, using the ct (clear all tabs), 280 * st (set one tab) and ch (horizontal cursor addressing) capabilities. 281 * This is done before if and is, so they can patch in case we blow this. 282 * Return nonzero if we set any tab stops, zero if not. 283 */ 284int | 242{ 243 char *bp, buf[1024]; 244 int settle; 245 246 bp = buf; 247 if (tgetstr("pc", &bp) != 0) /* Get/set pad character. */ 248 PC = buf[0]; 249 --- 27 unchanged lines hidden (view full) --- 277 278/* 279 * Set the hardware tabs on the terminal, using the ct (clear all tabs), 280 * st (set one tab) and ch (horizontal cursor addressing) capabilities. 281 * This is done before if and is, so they can patch in case we blow this. 282 * Return nonzero if we set any tab stops, zero if not. 283 */ 284int |
285set_tabs() | 285set_tabs(void) |
286{ 287 int c; 288 char *capsp, *clear_tabs; 289 char *set_column, *set_pos, *Set_tab; 290 char caps[1024]; 291 const char *tg_out; 292 293 capsp = caps; --- 33 unchanged lines hidden --- | 286{ 287 int c; 288 char *capsp, *clear_tabs; 289 char *set_column, *set_pos, *Set_tab; 290 char caps[1024]; 291 const char *tg_out; 292 293 capsp = caps; --- 33 unchanged lines hidden --- |