summaryrefslogtreecommitdiffstats
path: root/usr.bin/tset
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-08-30 08:27:31 +0000
committerpeter <peter@FreeBSD.org>1999-08-30 08:27:31 +0000
commitc87e1a3786e27be7585d42440432756b2cee5a43 (patch)
tree7eb93a330e1c165294cd2aa81de6a705c868830e /usr.bin/tset
parentfc261166e296372e82a6849cba92eb84748b4765 (diff)
downloadFreeBSD-src-c87e1a3786e27be7585d42440432756b2cee5a43.zip
FreeBSD-src-c87e1a3786e27be7585d42440432756b2cee5a43.tar.gz
Take a shot at making this work under termcap/terminfo ncurses. It
cheats a bit by accessing the termcap string buffer. A better solution is needed.
Diffstat (limited to 'usr.bin/tset')
-rw-r--r--usr.bin/tset/extern.h2
-rw-r--r--usr.bin/tset/map.c6
-rw-r--r--usr.bin/tset/set.c14
-rw-r--r--usr.bin/tset/tset.c36
4 files changed, 33 insertions, 25 deletions
diff --git a/usr.bin/tset/extern.h b/usr.bin/tset/extern.h
index 6d1be24..f1c1163 100644
--- a/usr.bin/tset/extern.h
+++ b/usr.bin/tset/extern.h
@@ -36,7 +36,7 @@
#include <termcap.h>
extern struct termios mode, oldmode;
-extern int columns, isreset, lines;
+extern int Columns, isreset, Lines;
extern int erasechar, intrchar, killchar;
void add_mapping __P((char *, char *));
diff --git a/usr.bin/tset/map.c b/usr.bin/tset/map.c
index 016afb1..4c11a67 100644
--- a/usr.bin/tset/map.c
+++ b/usr.bin/tset/map.c
@@ -47,7 +47,7 @@ static const char rcsid[] =
#include "extern.h"
extern speed_t Ospeed;
-speed_t baudrate __P((char *));
+speed_t tset_baudrate __P((char *));
/* Baud rate conditionals for mapping. */
#define GT 0x01
@@ -139,7 +139,7 @@ next: if (*arg == ':') {
if (arg == NULL)
goto badmopt;
*arg++ = '\0';
- mapp->speed = baudrate(p);
+ mapp->speed = tset_baudrate(p);
}
if (*arg == '\0') /* Non-optional type. */
@@ -236,7 +236,7 @@ SPEEDS speeds[] = {
};
speed_t
-baudrate(rate)
+tset_baudrate(rate)
char *rate;
{
SPEEDS *sp;
diff --git a/usr.bin/tset/set.c b/usr.bin/tset/set.c
index 0f30814..e5c52cf 100644
--- a/usr.bin/tset/set.c
+++ b/usr.bin/tset/set.c
@@ -285,13 +285,13 @@ set_tabs()
{
int c;
char *capsp, *clear_tabs;
- char *set_column, *set_pos, *set_tab, *tg_out;
+ char *set_column, *set_pos, *Set_tab, *tg_out;
char caps[1024];
capsp = caps;
- set_tab = tgetstr("st", &capsp);
+ Set_tab = tgetstr("st", &capsp);
- if (set_tab && (clear_tabs = tgetstr("ct", &capsp))) {
+ if (Set_tab && (clear_tabs = tgetstr("ct", &capsp))) {
(void)putc('\r', stderr); /* Force to left margin. */
tputs(clear_tabs, 0, outc);
}
@@ -299,8 +299,8 @@ set_tabs()
set_column = tgetstr("ch", &capsp);
set_pos = set_column ? NULL : tgetstr("cm", &capsp);
- if (set_tab) {
- for (c = 8; c < columns; c += 8) {
+ if (Set_tab) {
+ for (c = 8; c < Columns; c += 8) {
/*
* Get to the right column. "OOPS" is returned by
* tgoto() if it can't do the job. (*snarl*)
@@ -309,13 +309,13 @@ set_tabs()
if (set_column)
tg_out = tgoto(set_column, 0, c);
if (*tg_out == 'O' && set_pos)
- tg_out = tgoto(set_pos, c, lines - 1);
+ tg_out = tgoto(set_pos, c, Lines - 1);
if (*tg_out != 'O')
tputs(tg_out, 1, outc);
else
(void)fprintf(stderr, "%s", " ");
/* Set the tab. */
- tputs(set_tab, 0, outc);
+ tputs(Set_tab, 0, outc);
}
putc('\r', stderr);
return (1);
diff --git a/usr.bin/tset/tset.c b/usr.bin/tset/tset.c
index df6b5b4..c146547 100644
--- a/usr.bin/tset/tset.c
+++ b/usr.bin/tset/tset.c
@@ -66,7 +66,7 @@ int erasechar; /* new erase character */
int intrchar; /* new interrupt character */
int isreset; /* invoked as reset */
int killchar; /* new kill character */
-int lines, columns; /* window size */
+int Lines, Columns; /* window size */
speed_t Ospeed;
int
@@ -161,16 +161,16 @@ main(argc, argv)
ttype = get_termcap_entry(*argv, &tcapbuf);
if (!noset) {
- columns = tgetnum("co");
- lines = tgetnum("li");
+ Columns = tgetnum("co");
+ Lines = tgetnum("li");
#ifdef TIOCGWINSZ
/* Set window size */
(void)ioctl(STDERR_FILENO, TIOCGWINSZ, &win);
if (win.ws_row == 0 && win.ws_col == 0 &&
- lines > 0 && columns > 0) {
- win.ws_row = lines;
- win.ws_col = columns;
+ Lines > 0 && Columns > 0) {
+ win.ws_row = Lines;
+ win.ws_col = Columns;
(void)ioctl(STDERR_FILENO, TIOCSWINSZ, &win);
}
#endif
@@ -203,7 +203,8 @@ main(argc, argv)
if (Sflag) {
(void)printf("%s ", ttype);
- wrtermcap(tcapbuf);
+ if (strlen(tcapbuf) > 0)
+ wrtermcap(tcapbuf);
}
if (sflag) {
@@ -213,15 +214,22 @@ main(argc, argv)
*/
if ((p = getenv("SHELL")) &&
!strcmp(p + strlen(p) - 3, "csh")) {
- p = "set noglob;\nsetenv TERM %s;\nsetenv TERMCAP '";
- t = "';\nunset noglob;\n";
+ printf("set noglob;\nsetenv TERM %s;\n", ttype);
+ if (strlen(tcapbuf) > 0) {
+ printf("setenv TERMCAP '");
+ wrtermcap(tcapbuf);
+ printf("';\n");
+ }
+ printf("unset noglob;\n");
} else {
- p = "TERM=%s;\nTERMCAP='";
- t = "';\nexport TERMCAP TERM;\n";
+ printf("TERM=%s;\n", ttype);
+ if (strlen(tcapbuf) > 0) {
+ printf("TERMCAP='");
+ wrtermcap(tcapbuf);
+ printf("';\nexport TERMCAP;\n");
+ }
+ printf("export TERM;\n");
}
- (void)printf(p, ttype);
- wrtermcap(tcapbuf);
- (void)printf(t);
}
exit(0);
OpenPOWER on IntegriCloud