mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-17 15:27:36 +00:00
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.
This commit is contained in:
parent
046fbf6fe9
commit
18bfeb3d34
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=50638
@ -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 *));
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user